4

After accessing the Rest API (http://192.168.1.180/magento/index.php/rest/V1/products/SKU) to get the product details, the response is something like this:

{ "attribute_code": "image", "value": "/6/4/64275-152378-large.jpg" }, { "attribute_code": "small_image", "value": "/6/4/64275-152378-large.jpg" }, { "attribute_code": "thumbnail", "value": "/6/4/64275-152378-large.jpg" }

What should be the base url/prefix for the jpg in the attribute_code keys ?

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Dec 8, 2015 at 11:25
4
  • have you tried : api/rest/products/sku/images? Commented Dec 8, 2015 at 12:06
  • this link does not work in magento 2.0 Commented Dec 8, 2015 at 13:05
  • Magento 2 : /V1/products/:sku/media Commented Dec 8, 2015 at 13:18
  • Check my answer.. all the api's in 2.0 will give you an incomplete URL.. you can hardcode the directory path. Commented Dec 8, 2015 at 13:20

2 Answers 2

4

In Magento 2x the product image urls are all relative. It's possible some extension or usage of CDN could change the base path. You can call the the V1/store/StoreConfigs api and use the baseMediaUrl value to get the full path.

answered Jan 15, 2016 at 23:09
3

Found the URL on server directory. Just add a prefix to the URL.

Prefix: http://magento.com/pub/media/catalog/product/(url in API response)

answered Dec 8, 2015 at 13:07
1
  • This would be safe as long as no one has changed the Base URL for User Media Files value from Admin->Stores->General->Web. (This was the point which @Chuck was making in the other answer.) Commented Jul 18, 2017 at 11:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.