PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 10, 2022

[FIXED] How to resize media images in magento?

 November 10, 2022     e-commerce, magento, magento-1.6, magento-1.7     No comments   

Issue

I am using magento 1.7 version.I have some images with product.Now I want to show as a slider in detail page.my code is below:-

<?php if (count($_product->getMediaGalleryImages()) > 0): ?>  
<div class="more-views">

<div class="productsmallImage">
    <div id="slider2">
        <a class="buttons prev" href="javascript:;">left</a>
        <div class="viewport">                 
            <ul class="overview">            
                <?php foreach ($_product->getMediaGalleryImages() as $_image):?>
                <li>
                    <!--No lightbox on click of image-->
                  <a href="<?php echo $_image->getUrl();?>" title="<?php echo $_image->getName();?>" onclick="$('image').src = this.href; return false;">
                      <img src="<?php echo $_image->getUrl(); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
                  </a>
                </li>
                <?php endforeach; ?>
            </ul>
        </div>
        <a class="buttons next" href="javascript:;">right</a>
    </div>
</div>

In this count($_product->getMediaGalleryImages()) has value 4.All the images showing but need to resize them.Please help to do this.


Solution

Try to use the following construction for images output:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(56) ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />


Answered By - Yaroslav Rogoza
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing