Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Product thumbnail image in Assets tab is not refreshed when image is updated

Vote:
 

Using Commerce 10.4.3 and CMS 10.5.0, we are facing an issue with thumbnails images in Media panel and Assets tab are not being refreshed when products images are being updated.

I was able to resolve the issue by running schedule job "Clear Thumbnail Properties". However, I would really like to know the expected behavior when an image is updated. Shouldn't the thumbnail image be refreshed by default?

Thanks!

#202458
Mar 26, 2019 22:14
Vote:
 

Recently someone asked if when the Media is Deleted if it should be also be automatically Deleted from the Asset tab, and Quan said it isn't by default.

https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2018/2/assets-aren39t-removedunlinked-when-an-image-is-deleted/

I wonder if its the same with Updating the image? If so, you could add an OnSavingContent event, find Products with the asset and update them via API. Or as you said, just run the scheduled task.

#202459
Mar 26, 2019 23:54
Vote:
 

I think Islam is asking for another thing. However I find it strange because when I try to rotate an image with Image Editor, I can see the thumbnail, either here 

or here

are updated correctly without any other actions...

#202485
Mar 27, 2019 11:17
Vote:
 

I think we need more information Islam, can you please confirm what you mean by

 ...when products images are being updated

I assumed updated meant by uploading a new image to replace an existing image.

Quan assumes you meant updating the image in the Image Editor.

#202486
Mar 27, 2019 11:53
Vote:
 

Thanks Darren and Quan for your replies!

I meant what Quan mentioned. However, I am not using the interface to update images. We import images from an FTP using EPiServer APIs to add/update images. 

Here is a snapshot of the code:

//If file does not exist, create a new one
if (file == null)
file = _contentRepository.GetDefault<Whereoware.EPIServerMediaTypes.ImageFile>(groupImagesFolder.ContentLink, contentType.ID);
else
file = file.CreateWritableClone() as Whereoware.EPIServerMediaTypes.ImageFile;

My question now is whether thumbnails images are expected to be updated or not when image is updated programtically.

If the answer is yes, are we missing something in the code?

#202499
Mar 27, 2019 15:50
Vote:
 

I don't know which code is responsible for clearing the thumbnail, but if you want to be extra sure, you can just add this snippet to one of your initialization module (you can do it differently as long as you get the idea)

context.Locate.Advanced.GetInstance<IContentEvents>().SavedContent += (sender, e) => {
                if (!(e.Content is IContentMedia))
                {
                    return;
                }

                context.Locate.Advanced.GetInstance<ThumbnailManager>().CleanThumbnail((IContentMedia) e.Content, false);
            };
#202500
Mar 27, 2019 16:16
Vote:
 

Note that there is a catch here ThumbnailManager is an internal class, so you would have to use it with your own risk of your code being broken even with a minor (non major) upgrade. 

#202501
Mar 27, 2019 16:18
Vote:
 

Thanks Quan again!

It is just weird that calling "Save" for an ImageData object does not refresh the thumbnail by default.

#202507
Mar 27, 2019 18:59
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.