Changes to PictureRenderer.Optimizely

In version 3.2 of PictureRenderer.Optimizely it is possible to add any attribute to the rendered img element. This makes it possible to add e.g. custom data and itemprop attributes.

Version 3.2 introduces the PictureAttributes object that may be used as an input parameter when calling @Html.Picture.
It’s in the PictureAttributes object where you can add the custom attributes. Also note that some settings have been moved from the PictureProfile to the PictureAttributes object.

Read more about how to use v3.2 here.

It’s still possible to use PictureRenderer the “old” way, but it will not be possible to do that in the future v4.

Changes in the upcoming version 4

In v4 it will no longer be possible to render multiple images in the same picture element. The reason for this is that it will remove and simplify a large part of the code for PictureRenderer.
When having multiple images in the same picture element you also lose some of the benefits with the picture element. A better solution is to render multiple picture elements and show/hide them using css.

If you use the multi-image feature, I recommend changing to using more than one picture element.
I don’t think this feature is very widely used, but please let me know if you think this is a bad idea. Either in the comments below, or in the discussions section in the PictureRenderer repo.

Leave a Reply