Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get image thumbnail through SOAP call

I’m trying to display products in my store through a third party application using Magento’s web services API. When I query image data for an item using “catalog_product_attribute_media.list”, I get something like this:

Array
(
    [0] => Array
        (
            [file] => /a/k/akio-dresser.jpg
            [label] => 
            [position] => 1
            [exclude] => 1
            [url] => http://example.com/magento/media/catalog/product/a/k/akio-dresser.jpg
            [types] => Array
                (
                    [0] => thumbnail
                    [1] => small_image
                    [2] => image
                )

        )

)

This tells me that I should be able to get the “thumbnail” or “small_image” version of this image, but I can’t figure out how to actually do it. I’ve looked through the documentation and tried everything I could find but have had no success. Does anybody else know what SOAP call I could use? The call catalog_product_attribute_media.info seems to return exactly the same information, and catalog_product_attribute_media.types doesn’t seem to return anything at all.

like image 632
Syed Absar Avatar asked Dec 20 '25 22:12

Syed Absar


1 Answers

The API call result refers to the original file(s) for the product image(s), not the cached thumbnails/small images that are generated at runtime, i.e. when the product page is loaded.

The returned attributes correspond to the layout that you get in the admin page for the product. So a given image can be used for the main product image on the product page, the small image used in the category listings or the thumbnail used for when added to basket.

Magento scales these images on the fly, this is a much better arrangement that what you get with some older carts where you have to get images prepared to 'correct' sizes. However, that means that there is nothing but a cached copy of the thumbnail on disk with no API call to access it.

I faced a similar problem of wanting the product images outside of Magento. My workaround was to use a cron script to pull down the big original images that had changed in the last 24 hours, to then create the thumbnails with imagemagick and then use the new 'local' copy of the image.
This was no workaround, I actually wanted to do some command line processing to the thumbnails, to remove excess whitespace, sharpen the edges and add some extra vibrancy to the colours. This image processing was not realistic in real time and I did not want the default 'blurry' thumbnails anyway. An overnight cron-job on just the fresh images did the job for me.

like image 198
ʍǝɥʇɐɯ Avatar answered Dec 24 '25 12:12

ʍǝɥʇɐɯ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!