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


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?


Mar 26, 2019 22:14

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.

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.

Mar 26, 2019 23:54

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...

Mar 27, 2019 11:17

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.

Mar 27, 2019 11:53

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);
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?

Mar 27, 2019 15:50

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))

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

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. 

Mar 27, 2019 16:18

Thanks Quan again!

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

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.