Search code examples
image-scalingimageresizer

Accept QueryString for Image delivered by Controller


I'm trying to make a controller that delivers a random background image. I have a MVC route from /random-background.jpg to /MyController/RandomBackground, and it's returns File(backgroundImage, "image/jpeg"). This is working fine.

I've disabled the 404 plugin for all QueryStrings that ends with random-image, so the image is showing up. However, it won't take any parameters, such as random-background.jpg?width=200. &format=jpg doesn't have any effect either.

How do I get ImageResizer to accept this for a "real image"? Do I have to use ImageResizer.ImageJob? If so, I would love an example I can understand :)


Solution

  • ImageResizer V3 and earlier cannot 'post-process' the result of an MVC action or third-party HTTPHandler.

    You will need to use one of the virtual providers plugins, use URL rewriting, or implement your own IVirtualImageProvider.

    See the best practices guide for an explanation of 'why'.