Prestashop 1.7: hide thumbnails if there is only one image

Discover how to save space and optimize your product page if there is only a single image

If your product page has just a single image, there’s no need to display the same picture in a small format just below the cover image: it will be a simple repetition.

To avoid that, you have to perform this very quick and simple modification:

  1. Use your favorite Text Editor and open the file called product-cover-thumbnails.tpl inside /themes/your-theme/templates/catalog/_partials/
  2. If you cannot find this file, copy it from /themes/classic/templates/catalog/_partials/ and paste it into /themes/your-theme/templates/catalog/_partials/
  3. Look at this code:
    {block name='product_images'}
      <div class="js-qv-mask mask">
        <ul class="product-images js-qv-product-images">
          {foreach from=$product.images item=image}
            <li class="thumb-container">
              <img
                class="thumb js-thumb {if $image.id_image == $product.cover.id_image} selected {/if}"
                data-image-medium-src="{$image.bySize.medium_default.url}"
                data-image-large-src="{$image.bySize.large_default.url}"
                src="{$image.bySize.home_default.url}"
                alt="{$image.legend}"
                title="{$image.legend}
                width="100"
                itemprop="image"
              >
            </li>
          {/foreach}
        </ul>
      </div>
    {/block}
  4. Replace with:
    {if $product.images|@count > 1}
    {block name='product_images'}
    <div class="js-qv-mask mask">
    <ul class="product-images js-qv-product-images">
    {foreach from=$product.images item=image}
    <li class="thumb-container">
    <img
    class="thumb js-thumb {if $image.id_image == $product.cover.id_image} selected {/if}"
    data-image-medium-src="{$image.bySize.medium_default.url}"
    data-image-large-src="{$image.bySize.large_default.url}"
    src="{$image.bySize.home_default.url}"
    alt="{$image.legend}"
    title="{$image.legend}"
    width="100"
    itemprop="image"
    >
    </li>
    {/foreach}
    </ul>
    </div>
    {/block} {/if}
  5. Save the file
  6. It could be necessary to delete the cache of Prestashop (Advanced Parameters > Performance) and of your browser. (Please, be sure that “Recompile templates if the files have been updated” is enabled)

We are curious to read your opinion!

Leave a Reply

Your email address will not be published. Required fields are marked *

Respect for your privacy is our priority

Our website uses technical cookies to run properly and third-party cookies to generate reports on the use of navigation (statistical cookies). Show the list of cookies and the purpose of use
We can use technical cookies by law, but you have the right to choose whether or not to enable statistical cookies.

By enabling these cookies, you help us to provide you with a better experience.