1

I'm working with the new Magento default responsive theme (RWD).

On product view page I need to get the url of full size dimensions images.

In catalog/product/view/media.phtml I find

<?php
        $i=0;
        foreach ($this->getGalleryImages() as $_image):
            $_imageUrl = $this->helper('catalog/image')
                              ->init($_product, 'image', $_image->getFile())
                              ->keepFrame(false)
                              ->constrainOnly(true)
                              ->resize(1200);
    ?>
        <img id="image-<?php echo $i; ?>"
             class="gallery-image"
             src="<?php echo $_imageUrl; ?>"
             data-zoom-image="<?php echo  $_imageUrl; ?>" />
    <?php
        $i++;
        endforeach;
    ?>

As I said, I need to add one data attribute of tag with the url of full size image so I try this way

<?php
    $i=0;
    foreach ($this->getGalleryImages() as $_image):
        $_imageUrl = $this->helper('catalog/image')
                          ->init($_product, 'image', $_image->getFile())
                          ->keepFrame(false)
                          ->constrainOnly(true)
                          ->resize(1200);

        $_imageUrl_full = $this->helper('catalog/image')
                          ->init($_product, 'image', $_image->getFile());

?>
    <img id="image-<?php echo $i; ?>"
         class="gallery-image"
         src="<?php echo $_imageUrl; ?>"
         data-zoom-image="<?php echo  $_imageUrl; ?>"
         data-zoom-image-full="<?php echo  $_imageUrl_full; ?> />
<?php
    $i++;
    endforeach;
?>

...but I get the same image url (the full size one) for both "data-zoom-image" and "data-zoom-image-full".

I also try to clone the $_image object but no result.

Any advice?

P.S. I saw the question Issue with getting product image but I'm looping through media gallery images and not between products. My objective is to get different sized images and not different product images. And Last, as I said, I try to clone the $_image with no luck.

3
  • I don't see in your post where you are using clone...?
    – benmarks
    Jul 7 '14 at 14:30
  • The "clone way" is not in the code: i write that "I also try to clone the $_image object but no result." Jul 7 '14 at 15:27
  • Then your problem is the same as the other post. The issue is the reference and the helper instance, regardless of multiple products or not.
    – benmarks
    Jul 7 '14 at 18:06
0

to get full image try below code

    $_imageUrl_full=Mage::getModel('catalog/product_media_config') 
->getMediaUrl($_image->getFile());

$_imageUrl is right for small image

3
  • It works. Has it some issue with image caching or not? Jul 4 '14 at 17:06
  • Yes, you cannot create a product more than one cache image in Same page,
    – Amit Bera
    Jul 4 '14 at 17:11
  • 1
    @gattieri: Please verify the answer if it completes the requirement Jul 5 '14 at 6:37

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