How to check if product image added or place holder image used

  • magento check if product has image
  • magento get placeholder image
  • check the image of the product

Well, in Magento place holder image are always used when you get product URL or using Catalog_Helper_Image. But you know sometime, you don’t like this behavior and you need to be able to check if there is an image associated with the product or if the placeholder image will be used.

OK here is the solution
if ($_product->getSmallImage()=='no_selection' ) { //small_image is not set
// do your custom code
} else {
//display normal image?
}

This solution is used in many problem, for example when you need to handle images between product type Simple Product, Grouped Product and Configuration Product.
Thats it. Magento Programming is interesting.

Comments

Leave a Reply

Your email address will not be published.

4 − 2 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Security Code: