2

I am trying to get all magento product images

include 'app/Mage.php';
Mage::app(); 

$product = Mage::getModel('catalog/product')->load($product_id);  //some ID    

$productMediaConfig = Mage::getModel('catalog/product_media_config');

$baseImageUrl  = $productMediaConfig->getMediaUrl($product->getImage());
$smallImageUrl = $productMediaConfig->getMediaUrl($product->getSmallImage());
$thumbnailUrl  = $productMediaConfig->getMediaUrl($product->getThumbnail());

echo 'Base URL      : '. $baseImageUrl.'<br />';
echo 'small URl     : '. $smallImageUrl.'<br />';
echo 'thumbnail URl : '. $thumbnailUrl.'<br />';

The output for Base, small and thumbnail images is the same image
So how can I get all other product images?

4

You can get all images by getMediaGalleryImages() this function. ex.

foreach ($product->getMediaGalleryImages() as $image) {
        preload[]=$image->getUrl();
    }
1

It seems a copy/paste issue. Check the single quotes in your code

$productMediaConfig = Mage::getModel(‘catalog/product_media_config’);

Should be...

$productMediaConfig = Mage::getModel('catalog/product_media_config');
2
  • Yes, it was a copy/paste issue. Sorry. but the output for Base , Small and thumbnail images was the same image. I am still can't get all product images ?! May 27 '15 at 9:10
  • I have been edited the question to be more specific of the current issue. May 27 '15 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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