Jump to content

how does Prestashop generate image filenames


Recommended Posts

Dear all,

Because I'm facing some quality-problems with the standard PS thumbnail generation, I have made the thumbs with Photoshop. Now I want to replace the PS generated files, with the ones I created in Photoshop.

When I'm using 1 image per product, I noticed the filenames are a combination of ProductID-ProductID-size
for ex. 1-1-home.jpg

Now I have 2 images per product but I cannot find how PS renames the thumbfiles. now I have for example: 10-200.jpg.....

Does anybody know which rule PS uses to name the thumb-files?

Kind regards.

Link to comment
Share on other sites

I noticed the filenames are a combination of ProductID-ProductID-size for ex. 1-1-home.jpg

Yes you are right, but not 100% correct.
Actually the 2nd number should be image ID, not product ID.

It means you will have to upload your image first to get the image ID (generated by PrestaShop), then you can use this number to replace with your new photoshop image.

Yes, I agree, the image generation in PrestaShop is a problem.
Link to comment
Share on other sites

Thank you for your answer. I will try your method tonight. Then I will try to generate the ID's in excel so I can bulk-rename my files. At this moment I have around 200 products so that will be 200x2x6 (home,medium,thickbox etc)=2400 filenames to rename :-(

I'll let you know.

Link to comment
Share on other sites

So how would you code that into a theme?

I've got this backend code:

{$img_prod_dir}{$product->id|escape}-{$image->id|escape}-large.jpg

which produces this output in source code:

/img/p/23--large.jpg

leading me to believe {$image->id|escape} is wrong.

Does anybody know what it should be?

Link to comment
Share on other sites

leading me to believe {$image->id|escape} is wrong.

I guess you have not load the $image object in your PHP code.
I am not sure which page you are using this code.

check product page code as an example on how the image should be loaded.

1.3x
/product.php

1.4x
/controllers/ProductController.php
Link to comment
Share on other sites

  • 5 months later...

Hi i was used this code to display category image.

 

<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" />

 

 

But it shows the path like this-

/prestashop/img/c/-category.jpg

 

and i want like this to display image- "/prestashop/img/c/6-category.jpg"

here 6 is image id. Can any one help me how to write the code to get url like above.

 

 

Thanks

Link to comment
Share on other sites

×
×
  • Create New...