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 ?

4
  • have you tried : api/rest/products/sku/images?
    – Abdul
    Dec 8, 2015 at 12:06
  • this link does not work in magento 2.0
    – nr5
    Dec 8, 2015 at 13:05
  • Magento 2 : /V1/products/:sku/media
    – Abdul
    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.
    – nr5
    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.

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)

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.) Jul 18, 2017 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.