Sitecore: clear a single image from the media cache

We have created a custom image trimmer.

The idea is that it stores the query string in a field in an element. Then, when rendering, we add this query string to the image URL.

We added the getMediaStream pipeline. Inside this pipeline, we crop the image using an ImageProcessor based on the request that the image has.

It all works ... once.

After it worked, when the image is in the cache, and we never return to the getMediaStream pipeline. Because when you click, you do not change the image, but you change this request.

We are looking for a way so that when we save a new crop, we clear the media cache from this image. We tried the following:

var mediaItem = new MediaItem(imageField.MediaItem);
var media = MediaManager.GetMedia(mediaItem);
var mediaOptions = new MediaOptions();
var mediaStream = MediaManager.Cache.GetStream(media, mediaOptions);

MediaStream cachedStream = null;
MediaManager.Cache.AddStream(media, mediaOptions, mediaStream, out cachedStream);

- , : Could not create the buffer file needed for stream sharing

, ?

+4
1

, . Sitecore . , , Sitecore getmediastream.

, .

Sitecore ini . . , , .

0

All Articles