Magento 1.9 – How to Get Image URL with Proper Path

event-observerjsonmagento-1.9

<?php foreach ($temp as $product): ?>

<?php
    $id = $product['entity_id'];
    $img = $product['image'];
    $url = $product['url_path'];
    $small_image = $skinUrl.$product['small_image'];
    $small_img_lable = $product['small_image_label'];
    $thumbnail = $product['thumbnail'];
    $name = $product['name'];
    $price = $product['price'];
    $special_price = $product['special_price'];
    $size = $product['size'];
?>

<li class="product-grid_item product-tile">
<a class="product-image" href="<?php echo $url; ?>">
<div class="quickview">
    <button class="button button--s button--inverted">Quick View</button>
</div>
   <picture class="pimg1">
       <source srcset="<?php echo $small_image; ?>" media="(min-width: 400px)">
       <img srcset="<?php echo $small_image; ?>" alt="<?php echo $small_img_lable;?>">
  </picture>
  <picture class="pimg2">
      <source srcset="<?php echo $thumbnail; ?>" media="(min-width: 400px)">
      <img srcset="<?php echo $thumbnail; ?>" alt="<?php echo $thumbnail;?>">
 </picture>

$temp contain product attributes.And i have all the attibute data in json file, but can't get image url. How can I get this ?

"small_image":"/1/_/1_4_1.jpg","thumbnail":"/1/_/1_4_1.jpg"
this are my small image and thumbnail image values in json.

Best Answer

Try this :

$media = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$imageUrl = $media.'catalog/product/'. $product['image'];
Related Topic