C# .NET
Random sorting of list
You can do a random sorting of a list with LINQ by using:
list.OrderBy(Guid.NewGuid());
Installing ImageResizer in a new project
This will include the optional DiskCache that saves the scaled images to the disk.
Download from nuget:
- ImageResizer
- ImageResizer.Plugins.DiskCache (optional)
Put inside web.config following snippets:
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />
</configSections>
<system.webServer>
<modules>
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
And here comes the settings, you can change the values to whatever you want. They are quite self explained. Presets are pre defined scales like "medium" and "small" for me. You can either have it dynamically in each call to an image or set it it "onlyAllowPresets", which then uses those.
<resizer>
<plugins>
<add name="Presets" />
<add name="DiskCache" />
</plugins>
<presets onlyAllowPresets="false">
<preset name="medium" settings="width=600;height=600;scale=canvas" />
<preset name="small" settings="width=250;height=250;scale=canvas" />
</presets>
<clientcache minutes="1440" />
<diskCache dir="~/ImageResizer/" autoClean="false" hashModifiedDate="true" enabled="true" subfolders="32" cacheAccessTimeout="15000" />
</resizer>
Usage example:
- dev.yoursite.com/cat_1.jpg?preset=medium (With preset)
- dev.yoursite.com/cat_2.jpg?w=170&h=170&mode=pad
Published: 2016-08-22