Question

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

 <?php
  $Feature = explode(",",$_product->getResource()
  ->getAttribute('feature')->getFrontend()
  ->getValue($_product));

 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.

Was it helpful?

Solution

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'/>"; ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top