2

My "more view" images are being called by the following jQuery but it's leaving the thumb images huge at their original size. How can I resize them proportionally to 100px?

    var imagefile='<?php echo Mage::getBaseUrl('media');?>catalog/product'+file;
        jQuery("#ul-moreviews").prepend('<li>
<a class="thumb" title="'+label+'" onClick="$('+'image'+').src =this.href; changeLabel(this); return false;"     href="'+imagefile+'"><img title="'+label+'"src="'+imagefile+'"></a>
    <div class="caption-more"><h6>'+display_label+'</h6></div></li>');
                                    });     
  • how to get file value? – Amit Bera Sep 7 '14 at 13:13
2

you need resize image to php variable,it not good idea to resize directly using jquery.

foreach (Mage::getModel('catalog/product')->load($PrdoductId)->getMediaGalleryImages() 
as $_image): 

        $smallImage = Mage::helper('catalog/image')->init($_image, 'image')->resize(100)->setQuality(100);  
        endforeach;

code may like:

<?php
foreach (Mage::getModel('catalog/product')->load($PrdoductId())->getMediaGalleryImages() as $_image): 
$smallImage = Mage::helper('catalog/image')->init($_image, 'image')->resize(100)->setQuality(100);  
?>

 var imagefile='<?php echo $smallImage;?>';
        jQuery("#ul-moreviews").prepend('<li>
<a class="thumb" title="'+label+'" onClick="$('+'image'+').src =this.href; changeLabel(this); return false;"     href="'+imagefile+'"><img title="'+label+'"src="'+imagefile+'"></a>
    <div class="caption-more"><h6>'+display_label+'</h6></div></li>');
                                    });  
<?php endforeach; ?>

magento product image resize

below code:

Mage::helper('catalog/image')->init($_imageObject, 'image')->resize(100)->setQuality(100); 

Using resize(width,height) function image

<?php echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(301); ?> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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