Search code examples
imageresizer

ImageResizer downloads an image multiple times?


I followed this article: http://imageresizing.net/blog/2013/effortless-responsive-images.

My images are stored on a CDN and after installing all the nuget packages, I got resizing to work, but the problem I ran into was that I had to add style="max-width:100%" to most of the images.

Also, I have a page where the same image appears in multiple spots and I guess Image Resizer thinks that this these spots should contain different sizes of the image, so it downloads 3 different versions which sort of defeats the purpose. Is this how it is supposed to work naturally?

As an example, I have imageA.png on a page and it might be in the top, middle, and bottom. Image Resizer is downloading a different version for each section.

What is the best way to use imageresizer with srcset? I can't seem to find any thing on it.

If I use the DiskCache plugin, will this serve images to other users that request the same size or is it just for the current user requesting it?


Solution

  • I'll try to break apart your 4-question question.

    style="max-width:100%" to most of the images

    CSS like img {max-width:100%} can do this globally. This rule is present by default in many themes/frameworks.

    If an image appears in multiple spots, and those spots require differently sized/cropped versions of the image, there will be multiple requests. This is how it is supposed to work.

    ImageResizer responds to URLs like "image.jpg?width=100" Just use those URLs as you would when using srcset normally. Here's the webkit demo.

    DiskCache is not per-user. It is a global cache. It does re-apply authorization rules before serving from the cache.