I am learning Magento and I am trying to create a slider which show products' images. I am ok with the JS slider but I have problem when trying to get product images. I have tried these codes:

$productModel = Mage::getModel('catalog/product');
$product_1 = $productModel->load(1);
$name = $product_1->getData('name');
$description = $product_1->getData('description');
echo $name . '<br/>';
echo $description . '<br/>';
echo $product_1->getImageUrl();

The product's name and description are ok. But the image URL seems not right: http://hellomagento.dev/media/catalog/product/cache/1/image/265x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/image.jpg It's a Magento logo in gray color.

I have upload image for the product already.

Please help! Thank you!

  • Hi, can you please try with <?php echo Mage::helper('catalog/image')->init($product_1, 'small_image')->resize(200); ?> here, 200 is image size. Sep 17, 2015 at 13:13
  • Also check, have you assigned uploaded image to 'Small Image' from admin panel ? Sep 17, 2015 at 13:15

1 Answer 1


Make sure you have selected the base, small and thumbnail options for your product image as shown below. The Magento logo in grey is a placeholder for a product with no images selected.

enter image description here

  • When I apply it for a collection, the same problem happened. This is my code: <?php $product_collection = Mage::getModel('catalog/product')->getCollection()->setOrder('name', 'asc'); foreach($product_collection as $_product) { ?><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_product->getName(); ?>"><?php echo $_product->getName(); ?> - </a><?php echo "Product ID: "; echo $_product->getId() . " - "; echo $_product->getImageUrl(); echo "<br />"; } ?> Sep 17, 2015 at 14:40
  • In your collection you need to specify the attributes you want to collect, i.e. for image url use ->addAttributeToSelect('image')
    – paj
    Sep 17, 2015 at 14:47

Your Answer

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

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