![]() |
VOOZH | about |
dotnet add package SrcSet.Statiq --version 5.0.0
NuGet\Install-Package SrcSet.Statiq -Version 5.0.0
<PackageReference Include="SrcSet.Statiq" Version="5.0.0" />
<PackageVersion Include="SrcSet.Statiq" Version="5.0.0" />Directory.Packages.props
<PackageReference Include="SrcSet.Statiq" />Project file
paket add SrcSet.Statiq --version 5.0.0
#r "nuget: SrcSet.Statiq, 5.0.0"
#:package SrcSet.Statiq@5.0.0
#addin nuget:?package=SrcSet.Statiq&version=5.0.0Install as a Cake Addin
#tool nuget:?package=SrcSet.Statiq&version=5.0.0Install as a Cake Tool
Tools to create sets of responsive images for the web
👁 SrcSet
👁 SrcSet.Statiq
👁 SrcSet.Core
👁 Maintainability
👁 Reliability
👁 Security
This repository contains 3 projects:
dotnet tool install -g SrcSet
srcset {file or directory} [-r] [space delimited set of widths]
e.g.
srcset IMG_9687.jpg 500 1000
will resize the image to 500 and 1000 pixels wide, with the filenames IMG_9687-0500.jpg and IMG_9687-1000.jpg
srcset all_images/
will resize all images in the all_images directory (recursively if -r is included) to each of the default widths
This package contains a Statiq pipeline and HTML helper method to easily integrate responsive image generation into a Statiq site.
The process to accomplish this has two steps:
To create a set of responsive images, place the originals (to be resized) alongside your other assets, and then in your bootstrapper code, add:
bootstrapper.AddPipeline("SrcSet", new ResponsiveImages("**/*.jpg"));
where the optional parameter **/*.jpg is a glob pointing to the image assets to resize.
A custom set of widths can also be passed as a second parameter:
bootstrapper.AddPipeline("SrcSet", new ResponsiveImages("**/*.jpg", new ushort[] { 100, 200, 300 }));
In your Razor file, call the HTML helper to create an <img/> tag with the relevant attributes set:
@Html.Raw(ResponsiveImages.SrcSet("images/original.jpg"))
You can also customize the widths, default width, and add any other attributes here:
@Html.Raw(ResponsiveImages.SrcSet("images/original.jpg", new ushort[] { 100, 200, 300 }, 200))
@Html.Raw(ResponsiveImages.SrcSet("images/original.jpg", attributes: new Dictionary<string, string>
{
{ "class", "full-width" },
{ "alt", "don't forget about accessibility!" }
}
))
The "Core" library can be used to incorporate SrcSet's functionality into your own app.
First, create a new SrcSetManager:
var manager = new SrcSetManager();
Then invoke it's SaveSrcSet() method:
await manager.SaveSrcSet("file.png", SrcSetManager.DefaultSizes);
If you need more control than the default constructor and sizes provide, you can pass in a specific logging mechanism (other than the default Console.WriteLine) and list of widths:
var manager = new SrcSetManager(Image.LoadAsync, (string s) => logger.LogDebug(s));
await manager.SaveSrcSet("file.png", new ushort[] { 100, 200, 300 });
SrcSet uses ImageSharp under the hood, and therefore should theoretically support all file types that ImageSharp supports by entering the filename as a parameter, however when entering a directory as a parameter, file types are limited to:
Please be sure to read and follow ecoAPM's when submitting issues or pull requests.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.