We have an issue with resizing images where the old dimensions are getting cached--I think in Glass' lambda cache. I'm trying to figure out how to clear it once we update an image. The cached value has persisted across multiple app pool recycles, recompiles, and iisresets.

So say we have an image that's 1400x700 pixels. We get a new source image that's a more reasonable 500x250, so we go into the media library and attach the new version. This updates the Height and Width fields on the Sitecore item as expected. We publish the new image and view the page to discover it now has a black box around it. The image is the new 500x250 version, but the cached lambda expression is still passing the old dimensions to the .ashx.

The RenderImage call was originally in the format RenderImage(x => c.CurrentItem.Image, ...), which we then changed to RenderImage(x => Model.CurrentItem.Image, ...) and then RenderImage(Model.CurrentItem, x => x.Image). All three exhibited the same behavior, even with an iisreset in between.

I've also tried disabling the cache per Mike Edwards' answer here: Disabling the Glass lambda cache. Which, of course, makes me wonder if it's the lambda cache at all, although I'm at a complete loss for another explanation.

I am using Sitecore 8.1.

  • Ahem. So. Apparently all of our image fields have the height and width set in the Properties tab. So when you go to the Article item, find the Image field, and click the Properties link, it has the height and width in there; the old values, and it doesn't update when you attach a new version of the image. So now I'm off to find out if that's some built-in Sitecore functionality we need to override or just a result of the importer script that was used to create the Article items. Nov 28, 2016 at 16:20

1 Answer 1


This looks like a Sitecore Media Cache issue, and not a Glass.Mapper issue.

The reason I say this is that the Glass.Mapper expression cache cannot persist between application recycles, as the cache is stored in an in-memory dictionary.

By default, the Sitecore Media Cache is stored on disk, so those entries can persist for a while (and by default, it looks like they last for 90 days before being cleaned up)

My recommendation would be to clear out the media cache, (located here Website\App_Data\MediaCache\) and see if that solves your issue.

  • I tried that this morning, but unfortunately I'm getting the same result: still seeing the black fill. Nov 28, 2016 at 14:36
  • After wiping out the cache and reloading the page, a new cache for the image is created. I checked the .ini file for the cached image and it maintains the incorrect dimensions. I'm not sure if that tells anyone anything. Nov 28, 2016 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.