ErikHen / PictureRenderer

Simplify the rendering of HTML Picture elements for ASP.Net. With support for responsive, lazy loaded images.
MIT License
4 stars 5 forks source link

Feature request: Support for additional attributes #22

Open seanhakbb opened 2 months ago

seanhakbb commented 2 months ago

Hello and thanks for a great plugin!

It would be nice if it were possible to set our own attributes to the picture- and/or img-tag. For example we have a case where an image would use micro format schema and having an "itemprop" on the img tag.

But also some more advanced scenarios where a data attribute was applied.

Have you looked in to custom taghelpers? They are pretty useful for these type of helpers, I really like https://github.com/Jeavon/Slimsy and i think something similar would work nice with PictureRenderer and PictureRenderer.Optimizely.

ErikHen commented 2 months ago

Thanks! I will look into this after my summer vacation.

ErikHen commented 1 month ago

Hi @seanhakbb , take a look at v3.12. It's now possible to add any attribute to the img element. Note that this version introduces the PictureAttributes object which is sent in as a parameter to Picture.Render. From now on you use the PictureAttributes object for several settings. Some settings have been moved from the PictureProfile to the PictureAttributes object.

I have not created a taghelper or HTML-helper, because this library is also used in Blazor applications. I recommend creating your own HTML helper as a wrapper around PictureRenderer.