I have a custom pipeline processor that is patched in before the ResizeProcessor
in the getMediaStream
pipeline. When I request an image from sitecore that has no query parameters, such as site/-/media/.../my-image.jpg
, the media cache entry for that file will have the [key]
stored as the list of query parameters with all values set to 0 or false (depending on type). An example entry looks like this
[key]
?as=False&bc=0&h=0&iar=False&mh=0&mw=0&sc=0&thn=False&w=0
[extension]
jpg
[headers]
Content-Type: image/jpeg
[dataFile]
9ec21b9f3d964272a32da412422fec97.jpg
;-----
This is what I would expect, but a problem occurs when using custom parameters and requesting an image with parameters before requesting the original. Say I request the same image, but with my custom cropping parameters added, as such,
site/-/media/images/test/rally-scoob?w=1200&h=300&cha=l&c=1&hash=682947F3A745596DF0B8991F41BEC2709CED7755
which generates the following media cache entry:
[key]
?as=False&bc=0&h=300&iar=False&mh=0&mw=0&sc=0&thn=False&w=1200&cha=l
[extension]
jpg
[headers]
Content-Type: image/jpeg
[dataFile]
b0ae589092754a6b9376f0c6d76351cd.jpg
;-----
This is fine, as long as the image with the query parameters is requested after the original. If the order is switched, then the returned image for the parameterless image is not correct. The only workaround that I can think of is to append my custom parameters to the [key]
of the media entry in the same way that the other parameters are defaulted. The problem is that I'm not sure what needs to be patched in order to add custom parameters to the Media Cache keys by default.
Does anyone have any experience with altering the way that keys are stored in the media cache? Thanks in advance.