Obtain new thumbnails when image is replaced on server side

  • Posts: 634
  • Thank you received: 16
  • Hikashop Business
6 years 1 month ago #288382

-- HikaShop version -- : 3.3.0

Hi,

For some circumstances I have overwritten some images on server side with the same file name as the ones existing.

But,

when I reload the product list or product show, the thumbnails have not changed.

There's some way to have all thumbnails for one image be created again?

Thanks in advance.

--
Victor

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
6 years 1 month ago #288386

Hi,

Delete the thumbnail folders. HikaShop will recreate them on the fly as needed.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
  • Hikashop Business
6 years 1 month ago #288387

Thank you for your quick answer, I will further explain the need because this solution you provide is the one I want to avoid:

I have a site with about 45.000 products.
In average each product has 8 images.

The content is very stable in this site and only some 10 products change their images each day.

If I delete thumbnails by deleting a folder then each new product_list view invoked by a user is forcing the generation of at least 50 thumbnails,

if the site has an average of 50 visitors simultaneously this means that the server has a heavy duty of generating 2.500 thumbnails at once,

and this is only a conservative guess, my product views generate about 6 different thumbnail sizes per each picture... just do the math.

I need a method to just perform the deletion of all thumbnails for a certain image.

maybe you have some trick to share..

thank you.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
6 years 1 month ago #288389

Hi,

Realistic server load from recreating thumbnails aside, you didn't say how images are being replaced but it seems it's done directly on the server, like per FTP, means "outside" of HikaShop. So, then there's nothing HikaShop "knows" or can do about it.

If that's the way it is, the only "trick" I can think of is to create a custom upload script which looks for and deletes only the respective thumbnails of uploaded files in the various thumbnail folders.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
  • Hikashop Business
6 years 1 month ago #288390

We developed a massive upload component which read form a folder filled via FTP, then compares size of current and new image and depending on the result overwrites that file in upload folder.

We can develope a recursive search for all thumbs and delete them, but would be cleaner if we could let know hikashop the image has changed and let it do the work on the next render of the image.

What function should we invoke to let HikaShop know we changed that image?

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
6 years 1 month ago #288391

Hi,

Not sure how well your existing custom upload component handling finding and replacing image files is integrated with HikaShop - if at all - but since you have it, it'd sure be just a minor code amendment in this component for it to find and delete the respective thumbnails as well. Much less effort than developing yet another plugin just for this action. After all, your custom plugin already "knows" the file names, and it's merely about deleting them in a few specific other folders, meaning adding just a tiny snippet of code. No need to "let HikaShop know"... again, it'll know once a thumbnail is missing and will create it then... and only then, anyway. ;)


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13036
  • MODERATOR
6 years 1 month ago #288395

Hi,

I also think that it will be easier to modify the upload component to :
- list the subfolders of the upload folder
- delete the images with the same name in the sub folders
after the code which deletes the main image.
That should be only a few lines of code.

There is no function in HikaShop to let it know that the image has changed and that thumbnails need to be recreated.
When HikaShop deletes an image, it looks at the subfolders and delete the images with the same name, so that when HikaShop needs the thumbnails, it regenerates them automatically.

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
  • Hikashop Business
6 years 1 month ago #288430

That sounds interesting.

Is there a HikaShop function to trigger the deletion of the image so it deletes its thumbnails?

We are actually overwriting the image file in uploads folder, we could change to deleting it first with a HikaShop "official" method, otherwise as you say we can create a selective deletion method, but using HikaShop's set of functions would be cleaner and more reliable for further compatibility when we improve this component.

Best regards,

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
6 years 1 month ago #288431

Hello,

There is a code in HikaShop which will delete the thumbnails when a product image is deleted.
But there is no specific function to do that task ; it's just something handle by the core in specific condition.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.080 seconds
Powered by Kunena Forum