When installing 2SexyContent 5.3 (or newer), the ImageResizer from imageresizing.net is automatically installed. ImageResizer is a very powerful set of image tools that allows you to resize images by just adding some parameters to the image url.
Basic usage
Every image in your DotNetNuke website is ready for getting resized or cropped. Just add the follwing parameters to an image URL to see it in action:
Example: http://www.example.com/Portals/0/example.jpg?w=100&h=100
This will resize the original example.jpg to 100 x 100 px. There are plenty of other options you can add to any image url.
Modes
You can add a parameter „mode“ to change the behaviour of the image resizer. These are the most often used options:
- h=100
Constrain by height (while preserving the original ratio) - w=100
Constrain by width (while preserving the original ratio) - mode=max&h=100&w=100
Makes sure that both the width and height don’t exceed 100 px. (while preserving the original ratio) - w=100&h=100
Pads the image with whitespace - mode=crop&h=100&w=100
Makes sure the image is not more than 100 x 100 px. If the original ratio is different, the image is cropped.
Beyond width, height and mode, there are many other parameters you can add like Scale, Alignment, Format, Compression, Background Color. If you want to, you can even add a PDF preview plugin to ImageResizer! (more options documented on 2SexyContent.org or imageresizing.net).
Usage with 2SexyContent
Here’s how to add the image resizer to your 2SexyContent template. Create a content type with a file field, call it Image. In your template, write:
[Content:Image]?w=100&h=100&mode=crop (Token templates)
or @Content.Image?w=100&h=100?mode=crop (Razor templates)
The image resizer will crop the images to 100 x 100 px. Play around with these values to match your template. You or your customer can upload images directly from the camera – the template will make sure the image fits.
Caching?
By default, 2SexyContent contains the TinyCache plugin which offers a fixed-size cache of 30 mb. If you have a website with many images (a few hundreds), you should consider buying an ImageResizer license, which allows you to use the DiskCache plugin for production use.
More information about licensing: http://imageresizing.net/licenses
More about the new Thumbnailer on 2SexyContent.org
Download 2SexyContent for DotNetNuke
If you have questions, contact me at raphael.mueller@2sic.com.
Raphael