Unlike other ecommerce software such as VirtueMart, PestaShop here slightly complicates in order to make our e-commerce site faster and more responsive in the presence of large catalogs. To do this, it does not use a single folder for images, but creates a folder for each digit of the id_immage value, inserting the product images in the last folder that corresponds to the last digit of our ID number.


When we go to insert an image in a PrestaShop 1.5.X / 1.6.X and 1.7 product it populates the following fields in the ps_image table: id_image, id_product, postion, cover where:

  • the id_image field is AUTO_INCREMENT
  • the id_product field is the id of the product we are inserting / modifying
  • the position field is the order in case of multiple images
  • the cover field identifies the cover image by setting the value to 1 while the others the value is 0

Once the DB has been populated, load the image renaming it as id_image .jpg and create the various thumbnails set in the ps_imgage_type table ( Back office> Preferences> Images ).
The thumbnail name rule is very simple, the images will be id_image-nomeformato.jpg

Eg we have uploaded an image of a product, PrestaShop assigns ID 936 to this image, rename our image as 936.jpg and it will also create all the thumbnails by reading the ps_imgage_type table, let's say in the example that we only have home_default which is 124x124px, PrestaShop will create the 936-home_default.jpg file with the dimensions set in Back office> Preferences> Images .
PrestaShop will save these images in: img / p / 9/3/6 / where / img / p is the default folder for product images (/ img / c / is the category one)

Let's see in detail what happens when setting the product ID equal to 455 and loading a second image that takes ID 964:

In the ps_image table create the following records :

id_image id_product position cover
963 455 1 0
964 455 2 1

In the ps_image_lang table create the following records:

id_image id_lang legend
963 1 Product name
964 1 Product name

This table varies according to the languages we manage in e-commerce (you can upload a different image for each language) and the value set in the "Legend" field when we go to upload the image.

In the ps_image_shop table create the following records:

id_image id_shop cover
963 1 1
964 1 0

Prestashop multistore : this table also varies depending on whether the Multi-store management is activated in our e-commerce and the number of stores we have configured.

We will find our images in :
/ img / p / 9/6/3 / 963- home_default.jpg
/ img / p / 9/6/4 / 964- home_default.jpg

Prestashop then displays the images through the getImageLink function called up in the files of our Template.
If we have activated the understandable URL item in Back office> Preferences> URL and SEO , the product images will be renamed with the product name, greatly enhancing the SEO optimization of our site.

Optimizing the images of an e-commerce in PrestaShop : let's remember the importance of optimizing the images of our e-commerce in PrestaShop. We can use the TinyPNG API ( https://tinypng.com/ ) also through the excellent module for PrestaShop on Addons: https://addons.prestashop.com/it/website-performance/22488-compressore-di- images-with-tinypng.html . It is also possible to optimize the images locally with windows software such as FileOptimizer or perform the optimization via SSH access to your server. Image optimization will allow us to have faster loading times and better scores from Google.

Author: Loris Modena


For Ind Loris Modena , owner of Arte e Informatica , he began working in the IT sector in 1989 as a system engineer in charge of the maintenance and installation of IT systems. He started programming for the web in 1997 dealing with CGI programming in PERL and then moving on to programming in PHP and JavaScript. In this period he approaches the Open source world and the management of Linux servers.

PrestaShop Experts Program
PrestaShop Web Agency

Certified E-commerce Web Agency

Tecnoacquisti.com® is among the first Prestashop Platinum-certified agencies in Italy and in Europe. We specialize in helping small and medium-sized businesses sell online.

Consulting and Assistance

You can rely on our digital agency for advice or resolution of issues related to your online store or company website. 

Assistance | Check-UP | Hosting PrestaShop

Product added to wishlist