-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Possible to add custom attributes to img element + prepare for v4 (#23)
Introduce the PictureAttributes object as parameter, and add possibility to add custom attributes to img element.
- Loading branch information
Showing
10 changed files
with
382 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
| ||
using System.Collections.Generic; | ||
|
||
namespace PictureRenderer | ||
{ | ||
public class PictureAttributes | ||
{ | ||
/// <summary> | ||
/// img element alt attribute | ||
/// </summary> | ||
public string ImgAlt { get; set; } | ||
|
||
/// <summary> | ||
/// img element class attribute | ||
/// </summary> | ||
public string ImgClass { get; set; } | ||
|
||
/// <summary> | ||
/// img element decoding attribute. Default value: async. | ||
/// </summary> | ||
public ImageDecoding ImgDecoding { get; set; } | ||
|
||
/// <summary> | ||
/// img element fetchPriority attribute. Default value: none. | ||
/// </summary> | ||
public FetchPriority ImgFetchPriority { get; set; } | ||
|
||
/// <summary> | ||
/// Type of lazy loading. Currently supports browser native or none. Default value: browser native) | ||
/// </summary> | ||
public LazyLoading LazyLoading { get; set; } | ||
|
||
/// <summary> | ||
/// If true, width and height attributes will be rendered on the img element. | ||
/// </summary> | ||
public bool RenderImgWidthHeight { get; set; } | ||
|
||
/// <summary> | ||
/// May be used to add additional attributes (like data or itemprop attributes) to the img element. | ||
/// </summary> | ||
public Dictionary<string, string> ImgAdditionalAttributes { get; set; } | ||
|
||
public PictureAttributes() { | ||
ImgDecoding = ImageDecoding.Async; | ||
ImgFetchPriority = FetchPriority.None; | ||
RenderImgWidthHeight = false; | ||
LazyLoading = LazyLoading.Browser; | ||
ImgAdditionalAttributes = new Dictionary<string, string>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ASP.Net Picture Renderer | ||
Makes it easy to optimize images in (pixel) size, quality, file size, and image format. | ||
Images will be responsive, and can be lazy loaded.<br> | ||
It's a light-weight library, suitable for Blazor Webassembly. | ||
|
||
The Picture Renderer renders an [HTML picture element](https://webdesign.tutsplus.com/tutorials/quick-tip-how-to-use-html5-picture-for-responsive-images--cms-21015). The picture element presents a set of images in different sizes and formats. | ||
It’s then up to the browser to select the most appropriate image depending on screen resolution, viewport width, network speed, and the rules that you set up. | ||
|
||
Picture Renderer works very well together with a CMS where you might not be in control of the exact images that will be used. | ||
The content editor doesn't have to care about what aspect ratio, or size, the image has. The most optimal image will always be used.<br> | ||
Picture Renderer currently works together with [SixLabors/ImageSharp.Web](https://github.com/SixLabors/ImageSharp.Web), [Storyblok's Image service](https://www.storyblok.com/docs/image-service), and [Cloudflare image resizing](https://developers.cloudflare.com/images/image-resizing/). | ||
|
||
Read more about Picture Renderer [here](https://github.com/ErikHen/PictureRenderer). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.