Our.Umbraco.Slimsy
7.0.0
dotnet add package Our.Umbraco.Slimsy --version 7.0.0
NuGet\Install-Package Our.Umbraco.Slimsy -Version 7.0.0
<PackageReference Include="Our.Umbraco.Slimsy" Version="7.0.0" />
<PackageVersion Include="Our.Umbraco.Slimsy" Version="7.0.0" />
<PackageReference Include="Our.Umbraco.Slimsy" />
paket add Our.Umbraco.Slimsy --version 7.0.0
#r "nuget: Our.Umbraco.Slimsy, 7.0.0"
#:package Our.Umbraco.Slimsy@7.0.0
#addin nuget:?package=Our.Umbraco.Slimsy&version=7.0.0
#tool nuget:?package=Our.Umbraco.Slimsy&version=7.0.0
Slimsy
Effortless Responsive & Lazy Images with LazySizes and Umbraco
Slimsy v7 is made for Umbraco v17!
Slimsy v6 is made for Umbraco v14, v15 & v16 (it does also work with v17)!
Slimsy v5 is made for Umbraco v13.2 < v14!
Slimsy v4 is made for Umbraco v10, v11 & v12!

Release Downloads
Prerelease Downloads
Installation
1. Install from NuGet
2. Add .AddSlimsy() to program.cs before the call to the .Build() method
e.g.
builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
.AddDeliveryApi()
.AddComposers()
.AddSlimsy()
.Build();
3. Add to _ViewImports.cshtml
@using Slimsy.Enums
@using Slimsy.Extensions
@addTagHelper *, Slimsy
@inject Slimsy.Services.SlimsyService SlimsyService
4. Add lazysizes.min.js & to your templates/views
In your template add the JavaScript files
<script src="/scripts/lazysizes.min.js" async=""></script>
5. Ensure all img elements are set to display: block or display: inline-block;
e.g.
img {
display:block;
}
If you are using LQIP then you will also need to ensure img elements are set to width:100%;
e.g.
img {
display:block;
width:100%;
}
6. Use the <slimsy-picture> tag helper or manually adjust your image elements, adding data-srcset, data-src, sizes="auto" & class="lazyload" attributes
<slimsy-picture media-item="@person.Photo" width="323" height="300" css-class="myClass" render-lqip="true" render-webp-alternative="true"></slimsy-picture>
Use the GetSrcSetUrls UrlHelper extension methods to generate your data-srcset attributes. For these methods to function correctly your image property types should use the built-in Image Cropper.
<div class="employee-grid__item__image">
<img data-srcset="@Url.GetSrcSetUrls(person.Photo, 323, 300)" srcset="@Url.GetSrcSetUrls(person.Photo, 250, 250, quality: 40)" data-sizes="auto" class="lazyload"/>
</div>
Or inject SlimsyService into your ViewComponents
private readonly SlimsyService _slimsyService;
public ResponsiveImageViewComponent(SlimsyService slimsyService)
{
_slimsyService = slimsyService;
}
7 (optional). Adjust the rendering of your Richtext editors
e.g.
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem>
@{
var slimsyDefaultPictureSources = SlimsyOptions.Value.TagHelper.DefaultPictureSources.Select(x => x.Extension).ToArray();
}
<div style="padding: 20px">
@Html.ConvertImgToResponsive(Model.Content, "richText", renderPicture: true, pictureSources: slimsyDefaultPictureSources)
</div>
8 (optional). Adjust the renderer of media within the Block Grid editor
e.g.
@using Umbraco.Cms.Core
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem>
@{
var typedMediaPickerSingle = Model.Content.Value<Umbraco.Cms.Core.Models.MediaWithCrops>("image");
if (typedMediaPickerSingle != null)
{
var sourceWidth = typedMediaPickerSingle.Value<int>(Constants.Conventions.Media.Width);
var sourceHeight = typedMediaPickerSingle.Value<int>(Constants.Conventions.Media.Height);
<slimsy-picture media-item="@typedMediaPickerSingle" width="sourceWidth" height="sourceHeight" css-class="object-fit:cover; width:100%; height:100%;" render-lqip="true"></slimsy-picture>
} else {
<p>Missing image</p>
}
}
Options
Add/Edit appsettings.json
"Slimsy": {
"WidthStep": 180,
"UseCropAsSrc": false,
"DefaultQuality": 70,
"Format": "",
"BackgroundColor": "",
"AppendSourceDimensions": true,
"EncodeCommas": true,
"AutoOrient": true
}
or edit Startup.cs to modify SlimsyOptions
.AddSlimsy(options =>
{
options.DefaultQuality = 60;
options.WidthStep = 60;
options.UseCropAsSrc = true;
})
TagHelper also has some options in appsettings.json
- SingleSources - allows specific file extensions to only render a single source
- DefaultPictureSources - allows multiple picture sources to be defined, example below is for both avif and webp formats
- ImageDimensions - defines if width and height attributes should be rendered on the
imgtag
e.g.
"Slimsy": {
"WidthStep": 180,
"UseCropAsSrc": true,
"DefaultQuality": 70,
"TagHelper": {
"SingleSources": [ "gif" ],
"DefaultPictureSources": [
{
"Extension": "avif",
"Quality": 60
},
{
"Extension": "webp",
"Quality": 70
}
],
"ImageDimensions": true
}
}
TagHelper has new parameters
decorativewhich rendersrole="presentation"on theimgtagfetch-prioritywhich renders on theimgtag, for examplefetchpriority="high"image-crop-modespecifies a crop mode such as "Pad"image-crop-anchorused with crop-mode to set where cropping should be focussedloadingyou can set toEagerto not lazy load, useful for optimzing LCP on the first image rendered on the pagemobile-crop-aliasallows you to specify a separate crop to use for mobile/smaller viewports
Mobile Crop Support
The <slimsy-picture> tag helper supports separate mobile crops for responsive images. When you specify both crop-alias and mobile-crop-alias, Slimsy will:
- Generate mobile-optimized sources for smaller viewports using the mobile crop
- Generate desktop sources for larger viewports using the main crop
- Automatically apply media queries to serve the appropriate source based on viewport width
The mobile width threshold can be configured in appsettings.json (<em>it will default to 720 if not specified in the settings</em>):
"Slimsy": {
"MobileWidth": 720
}
Example Usage
<slimsy-picture
media-item="@Model.HeroImage"
crop-alias="desktop"
mobile-crop-alias="mobile"
css-class="hero-image"
render-lqip="true">
</slimsy-picture>
This will generate:
- Mobile sources using the "mobile" crop for viewports up to the configured mobile width (default 720px)
- Desktop sources using the "desktop" crop for larger viewports
- Appropriate media queries to serve the correct image based on screen size
How to use AVIF format in v4.1+
There is not currently a AVIF encoder for ImageSharp, keep an eye on https://github.com/hey-red/ImageSharp.Heif which has amditions of adding a encoder in the future.
Cloudflare Image Resizing does support AVIF encoding and this can be used by Slimsy.
1. Install the CloudflareImageUrlGenerator package
See https://github.com/Jeavon/CloudflareImageUrlGenerator for full details.
dotnet add package Umbraco.Community.CloudflareImageUrlGenerator
2. Add to Startup.cs in the ConfigureServices method
.AddCloudflareImageUrlGenerator()
3. Enable Image Resizing on Cloudflare
https://developers.cloudflare.com/images/image-resizing/enable-image-resizing/
4. Set the avif format as a DefaultPictureSources and enable AppendSourceDimensions in appsettings.json
e.g.
"Slimsy": {
"AppendSourceDimensions": true,
"TagHelper": {
"DefaultPictureSources": [
{
"Extension": "avif",
"Quality": 60
},
{
"Extension": "webp",
"Quality": 70
}
]
}
}
5. Check the rendered sources
Image paths for avif and webp should begin with /cdn-cgi/image/format=avif,quality=70
Lazysizes.js
Lazysizes.js is awesome and it's part of what makes Slimsy so easy to implement. If you need to find out more information about it or how to hook into it's Javascript events be sure to check out it's GitHub
Test Site & Source Code
A test site is included in the solution, the username and password for Umbraco are admin@admin.com/password1234567890
Credits and references
This project includes LazySizes which is MIT licensed.
Without the amazing ImageSharp this package wouldn't exist, so many thanks go to James and all the SixLabors team for creating ImageSharp!
Many thanks to Douglas Robar for naming Slimsy.
Change log
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Umbraco.Cms.Web.Common (>= 17.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.0 | 589 | 1/12/2026 |
| 6.0.4 | 1,734 | 8/9/2025 |
| 6.0.3 | 938 | 6/13/2025 |
| 6.0.2 | 708 | 5/6/2025 |
| 6.0.1 | 1,382 | 7/25/2024 |
| 6.0.0 | 351 | 5/30/2024 |
| 6.0.0-beta2 | 206 | 5/8/2024 |
| 6.0.0-beta1 | 204 | 4/18/2024 |
| 5.1.4 | 2,942 | 8/8/2025 |
| 5.1.3 | 1,565 | 6/13/2025 |
| 5.1.2 | 26,819 | 5/8/2024 |
| 5.1.1 | 1,929 | 4/3/2024 |
| 5.1.0 | 2,437 | 3/18/2024 |
| 5.0.0 | 6,326 | 3/8/2024 |
| 4.2.1 | 1,369 | 4/4/2024 |
| 4.2.0 | 465 | 3/18/2024 |
| 4.1.0 | 14,736 | 9/22/2023 |
| 4.1.0-beta4 | 3,487 | 8/9/2023 |
| 4.1.0-beta3 | 1,190 | 7/20/2023 |
| 4.1.0-beta2 | 982 | 7/13/2023 |
| 4.1.0-beta1 | 859 | 6/29/2023 |
| 4.0.3 | 10,194 | 4/5/2023 |
| 4.0.2 | 10,158 | 11/25/2022 |
| 4.0.1 | 1,110 | 11/21/2022 |
| 4.0.0 | 9,175 | 9/20/2022 |
| 4.0.0-beta1 | 948 | 8/3/2022 |
| 3.0.0 | 42,172 | 5/22/2020 |
| 3.0.0-beta5 | 1,616 | 5/14/2020 |
| 3.0.0-beta4 | 1,172 | 4/9/2020 |
| 3.0.0-beta3 | 4,942 | 10/15/2019 |
| 3.0.0-beta2 | 2,658 | 7/29/2019 |
| 3.0.0-beta1 | 5,076 | 4/2/2019 |
| 2.1.0-beta2 | 5,535 | 10/3/2018 |
| 2.1.0-beta1 | 1,488 | 10/2/2018 |
| 2.0.0 | 24,786 | 4/27/2018 |
| 2.0.0-beta4 | 2,167 | 3/14/2018 |
| 2.0.0-beta3 | 2,915 | 1/5/2018 |
| 2.0.0-beta2 | 2,141 | 10/31/2017 |
| 2.0.0-beta1 | 1,746 | 10/25/2017 |
| 1.1.7 | 40,319 | 2/3/2016 |
| 1.1.6 | 3,937 | 11/3/2015 |
| 1.1.4 | 8,652 | 2/26/2015 |