My images are not at the right size in the list pages, what can I do?

My images are not correctly resized in the list pages of magento2, so my pages are heavy and the download is slow....if you are in the same case what to do ?

It may be a malfunction, maybe magento2 can not resize the image because gd is not installed or it does not have the rights on your server in this case here are 2 points to check:

1) Check that the GD library that allows you to resize images is installed on your server
.

 apt-get install php70-gd 
 

2) Check the rights on the folder /pub/media

. Another point to check : 3) Configure the right sizes for in your theme (in your theme folder in /etc/view.xml)

. like this:

 <view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
    <media>
        <images module="Magento_Catalog">
            <image id="category_page_grid" type="small_image">
               <width>270</width>
                <height>291</height>
            </image>
            <image id="category_page_grid-1" type="small_image">
                <width>270</width>
                <height>291</height>
            </image>
            <image id="category_page_list" type="small_image">
                 <width>270</width>
                <height>291</height>
            </image>
        </images>
    </media>
</view>

This should help you. You can also use the following command to compress your images:

php <magento install dir > /bin/magento catalog:images:resize

This will compress all the images present for your site, personally I prefer to use the jpegoptim commands if you are under linux try it, it compresses a little better. I hope it will help you. Pierre
Books that can help you :
  • Livre Magento 2 Developer's Guide by Branko
  • Livre Mastering Magento2 Second Edition
  • Livre Magento 2 Cookbook
Questions about this lesson
No questions for this lesson. Be the first !

You must be logged in to ask for help on a lesson.