MDVA-36832: Images duplicate on pages with 768px view width - image

I am using Magento 2.3.4 and have a problem with the site builder displaying 2 images. There is a patch available but it does not support Magento version 2.3.4.
Does anyone have a solution for this problem?
MDVA-36832: Images duplicate on pages with 768px view width
https://support.magento.com/hc/en-us/articles/4402390637453-MDVA-36832-Images-duplicate-on-pages-with-768px-view-width

By default Magento displays the search results through the template;
app/design/frontend/YOURPACKAGE/YOURTHEME/template/catalog/product/list.phtml
You wanted to change that then the best thing you could do is follow the advice in the following link and designate a custom template to display your results by copying and renaming the list.phtml file;
Magento design update to replace list.phtml on search results page only
You could then customise it however you want. The section you would change is the following code which, as you can see ( the ->resize(135) part) is resizing your small product image to 135px. Change that to 400 and assuming the small image itself is not smaller than 400px wide then it wants to be pixellated.
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

Related

Magento 1.9.3 Display alternative image on hover on category page

I want to display an alternative image on hover on category page by assigning it in Product Information -> Images. I have created an attribute hover_image with the parameters Scope-Global, Catalog Input Type-Media Image, Apply to All Product Types. Added the attribute to the set. What should I do next? Thank you
To show the alternative hover image on category page. You need to make changes in Product Listing template in your current theme template/catalog/product/list.phtml.
As you have already created the media type attribute 'hover_image'. So you need to fetch hover_image type image like below:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'hover_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'hover_image'), null, true) ?>" />
Now you need to use javascript to apply hover effect on product images to hide the original image and show hover image.

Change Magento image size on search results page

I have changed the size of the images on the category pages from 135px to 400px. It now shows 3 columns with 400px images. This works fine! BUT I want the search result page to look the same as the category page. It already has 3 columns and the images are displayed as 400px. The only problem is that it still loads a 135px small image. Now the images are very blurry. How do I change this so it will load a 400px image?
Thank you
By default Magento displays the search results through the template;
app/design/frontend/YOURPACKAGE/YOURTHEME/template/catalog/product/list.phtml
I you wanted to change that then the best thing you could do is follow the advice in the following link and designate a custom template to display your results by copying and renaming the list.phtml file;
Magento design update to replace list.phtml on search results page only
You could then customise it however you want. The section you would change is the following code which, as you can see ( the ->resize(135) part) is resizing your small product image to 135px. Change that to 400 and assuming the small image itself is not smaller than 400px wide then it want be pixellated.
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
This can only be done through CSS. The CSS depends on the theme your using.

Magento 1.9.0.1 Image Size

I am using Magento 1.9.0.1.
When I go on a Category to view the products, All products are shown in square boxes.
As my images are rectangle, I can see the white space on left and right sides of the images.
Please advise how to edit the code so that images are shown rectangle shape (hight:300px width:200px).
Thanks
Take a look #
/app/design/frontend/default/{theme}/template/catalog/product/list.phtml
Change resize(width, height)
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(158, 150); ?>
Use this code for product images in list.phtml file(app/design/frontend/[current package]/[current theme]/template/catalog/product/list.phtml)
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(false)->resize($width, $height); ?>
Hope this helps! Thanks.

translate image K2 using joomfish

In a standard Joomla+Joomfish installation, when translating an article, there is the option to upload a different image for the translation (e.g. French packaging vs. English packaging).
When translating K2 items, I do not see an option to provide a translated image to the item. Have I turned off a setting somewhere or is this standard Joomfish feature not available when working with K2?
I've found a possible solution. Maybe it's quite a trick, but it works.
Since K2 doesn't store the path to the image into the database, I've used other fields that are stored. In particular, I've used the image_credits field.
In that field I insert the path to the image (/images/myimage.jpg) that I've uploaded on the server via ftp or via any other means that allow you to upload a picture into the image folder.
Now I've made some minor modifications into the template overrides of the item, adding an else branch to the if that manage the image
<?php else:
if(!empty($this->item->image_credits)): ?>
<figure class="itemImageBlock">
<a class="itemImage modal" rel="{handler: 'image'}" href="<?php echo $this->item->image_credits; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>">
<img src="<?php echo $this->item->image_credits; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:100%; height:auto;" />
</a>
</figure>
<?php endif; ?>
That's it. Now I can "translate" the image using Joomfish

Programmatically get the width and height of a product image in Magento?

Inside Magento templating code I want to get the width and height of the original product image (uploaded by admin when creating product), so as to make according adjustments.
How can I do this? Thus far I have:
$this->helper('catalog/image')->init($_product, 'image')
Does this have any methods that would allow me to retrieve the original dimensions of the product image? Such as:
$this->helper('catalog/image')->init($_product, 'image')->getWidth()
Or something?
Thanks!
Just found it in the docs: http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Helper_Image.html
Seems it's:
$this->helper('catalog/image')->init($_product, 'image')->getOriginalHeight()
$this->helper('catalog/image')->init($_product, 'image')->getOriginalWidth()

Resources