getting product image from js

mysz123
New Member
1 0 0

Hey,
There is way to get the products images from js in product page without
touch the product.liquid?

 

Thanks!

Alon Golan

0 Likes
PaulNewton
Shopify Partner
2583 136 472

https://shopify.dev/docs/themes/ajax-api/reference/product

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes

Yes. Every product has a JSON endpoint which contains the image's URL in it plus much more data.

For example, this product:

https://colourpop.com/products/glisten-up-vitamin-c

Can have most of its information viewed by adding .json at the end of the URL.

https://colourpop.com/products/glisten-up-vitamin-c.json

You just need to do a GET call of the product you want and get the image.
Naturally it requires basic Javascript knowledge to do so which is beyond the scope of this answer.

Kind regards,
Diego

◦ Product page slider & thumbnails with swiping for free themes: Minimal | Debut | Brooklyn | Supply
◦ Replace apps with simple copy/paste code snippets. Examples clicking here.
0 Likes