How can I extract product images from JS on a product page?

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

Thanks!

Alon Golan

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

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