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.
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...
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.
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 oneif (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?
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);
};
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.
Thanks Quan again!
It is just weird that calling "Save" for an ImageData object does not refresh the thumbnail by default.
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!