Allows you to specify the default settings to use when certain settings are omitted. Currently supports ScaleMode defaults. May be extended to allow defaults for other settings in the future - please create an idea for additional features you'd like to see.
<add name="DefaultSettings" />to the
<resizer> ... <defaultsettings explicitSizeScaleMode="DownscaleOnly" maxSizeScaleMode="DownscaleOnly" /> ... </resizer>
explicitSizeScaleModeis the default ScaleMode value to use when
heightare being used
maxSizeScaleModeis the default ScaleMode value to use when
maxheightare being used, or when
Valid ScaleMode values:
DownscaleOnly- The default. Only downsamples images - never enlarges. If an image is smaller than 'width' and 'height', the image coordinates are used instead.
UpscaleOnly- Only upscales (zooms) images - never downsamples except to meet web.config restrictions. If an image is larger than 'width' and 'height', the image coordinates are used instead.
Both- Upscales and downscales images according to 'width' and 'height', within web.config restrictions.
UpscaleCanvas- When the image is smaller than the requested size, padding is added instead of stretching the image.
anchorcan be used to determine where the padding is added.
On October 22, a 1-question survey was conducted asking users to vote one which ScaleMode defaults made the most sense.
Should &scale=both be the default instead of &scale=downscaleonly?
- 20% (10 votes) for Yes! I think that (by default) both maxwidth/maxheight and width/height should upscale an image if the original is smaller than the specified size.
- 34% (17 votes) for Only for width/height - upscaling makes sense for width/height because they specify an exact size, but not for maxwidth/maxheight, which only imply a maximum size.
- 46% (23 votes) for No! Leave it the way it is - if the image is smaller than width/height, it should remain the original size unless &scale=both is set.
In addition, one user wrote in a suggestion for scale=UpscaleCanvas to be the default instead.
Unexpectedly, 46% of users wanted to keep the existing behavior, having images to revert to their original size when smaller regardless of exact (width,height) or maximum (maxwidth,maxheight) size specification. Many users have contacted support, surprised by that behavior, and I had expected nobody to like (or expect) it.
So, nothing has changed. The defaults are the same as in V3, V2, and V1. But, we've introduced this new plugin for the 34% & 20% groups.
If you voted for 'Only for width/height', use
<defaultsettings explicitSizeScaleMode="Both" />
If you voted "Yes!", use
If you voted for upscaling the canvas, use
Hopefully this will help make everyone happy - feel free to contact me at firstname.lastname@example.org or create an idea if you have ideas or suggestions, I'm always willing and eager to make the Image Resizer easier to understand and use.
This plugin (DefaultSettings plugin) is part of the Essential edition
Where is the plugins section?
<plugins> section is located in Web.config, and is nested inside the
<resizer> element, which is nested inside
<configuration>. For examples, see this sample Web.config file.
Where can I find the dll?
We prefer that you install via NuGet, but you can also find the plugin DLL files in the /dlls/release folder of your download.
How do I typically install a plugin via Web.Config?
- In Visual Studio, right click on your project and choose "Add reference". Browse to the plugin DLL and click "OK".
- In the <plugins> section of Web.config, insert <add name="PluginName" />
- Look at the plugin documentation to see what configuration options (if any) are available.