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 ?
-
have you tried : api/rest/products/sku/images?Abdul– Abdul2015年12月08日 12:06:24 +00:00Commented Dec 8, 2015 at 12:06
-
this link does not work in magento 2.0devdoe– devdoe2015年12月08日 13:05:45 +00:00Commented Dec 8, 2015 at 13:05
-
Magento 2 : /V1/products/:sku/mediaAbdul– Abdul2015年12月08日 13:18:20 +00:00Commented 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.devdoe– devdoe2015年12月08日 13:20:26 +00:00Commented Dec 8, 2015 at 13:20
2 Answers 2
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.
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)
-
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.)Scott C Wilson– Scott C Wilson2017年07月18日 11:01:32 +00:00Commented Jul 18, 2017 at 11:01
Explore related questions
See similar questions with these tags.