Any way to restrict the full resolution image from being served up with Imageprocessor in Umbraco?

822 Views Asked by At

I'm working on a photography website in which full resolution photos can be uploaded but full-res should not be able to be displayed/accessed (download of the full res will take place through a token.)

I've tried the "restrictTo" setting but resolutions need to not be reliant on specified dimensions.

Is there a way to have myphoto.jpg by default without a querystring display at for example 700x700 yet still have the full resolution file available through a token download? Pretty much, an image without a querystring is still processed by Imageprocessor but with a default resize rule.

2

There are 2 best solutions below

1
On

I would use a query string for the image.

url?width=1400&height=900&mode=crop&anchor=center

I would also use a lazy load so the page loads faster with small blurry images and then afterwards replaces them all with the full res or querystring for max size you want to display at.

I wrote a script for this. http://www.codeshare.co.uk/blog/lazy-loading-images/

Also on my site now, when I upload an image, I automatically resize it down to 1080p resolution when it saves. So I can upload a massive image and not have to worry about resizing it first or it taking up too much space on my server.

Here's the code for that too http://www.codeshare.co.uk/blog/automatically-resize-your-media-images-in-umbraco/

0
On

I can request an image with a native width of 5000px by myphoto.jpg?width=1400 but the resulting image is the full 5000px width image, why doesn't the max width 1400px image serve up?

If you are getting the full image back it means something has gone wrong. (You've probably ran out of contiguous memory) so make sure you're in 64bit mode.

maxWidth restricts the resize param to an upper limit only. So does nothing on it's own.

What you are probably looking for is the ValidatingRequest event

http://imageprocessor.org/imageprocessor-web/imageprocessingmodule/#events

I would first set ImageProcessor.Web to intercept all image requests in the processing.config file by changing the interceptAllRequests property. That will ensure you capture any attempts to view the image without a token.

In the event you can cancel the request and also alter/add any querystring parameters to limit your size transparently without showing the querystring to the end user.