In magento1.9.2.4 when I created multiple select attribute with options and images for those options are placed in skin/frontend/<my_package>/<my_theme>/images/ and called the attribute in list.phtml like

  $Feature = explode(",",$_product->getResource()

 foreach($Feature as $key => $value): ?>

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."frontend/<package_name>/<theme_name>/images/".$value.".png'/>"; ?>

<?php endforeach; ?>

Now only the first image of the option is displaying. Other images are broken. When I Inspected the element in browser there was space before the image name. am not able to figure out the mistake. Kindly help me please.

Also when the image is clicked it should redirect to the respective product details page.

1 Answer 1


I am not getting the exact problem but if you are facing the space issue then use trim() function to remove extra spaces as:

<?php echo "<img src='".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."frontend/<package_name>/<theme_name>/images/".trim($value).".png'/>"; ?>

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.