Can you retrieve product images from js on Shopify without altering product.liquid?

mysz123
Visitor
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

Replies 2 (2)

PaulNewton
Shopify Partner
6274 573 1319

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

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


diego_ezfy
Shopify Partner
2935 562 883

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

◦ Follow my blog & youtube for coding tutorials. Most questions in here are already answered there!
◦ Top #4 Shopify Expert, 24h reply. Click here to hire me.
Download copy/paste code snippets that can replace most apps.