Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am successfully using the package, but am struggling with some parameters:
In the docs for Slimsy 2.0, the example with a predefined ratio contains the following line:
<img data-srcset="@Url.GetSrcSetUrls(featureImage, 1920, 0, ratio)" data-src="@Url.GetCropUrl(featureImage, 270, 161)" sizes="auto" class="lazyload" >
I was wondering where the Image Sizes came from, and what their meaning was:
Also, can someone point me to a good explanation of the data-srcset and data-src attributes?
Any insides appreciated.
Great to hear you have the package working successfully!
On your question about the width of 1920 for the ratio method, I've had a look and I'm not sure why we even need a width and height parameter on this method as the ratio object is all that's needed. I will check will William who wrote this method to see if I'm missing something in my understanding or if we can drop the width and height parameters for this overload.
The 270, 161 parameters determine the dimensions of the image that would be displayed on browsers that don't suport img-srcset (see below)
The data-src attribute is used for browsers that don't support img-srcset and where you haven't included a polyfill. It's optional so you can drop it if you don't require the fallback. Further info on this here
Hope that's helpful.
Thanks for the prompt answer!
Yeah, the width parameter seems not needed to me as well.
I have a follow-up question but will make it a new one...
No problem, William has removed both the width and height parameters from this overload as they were not needed. You can find this in the current beta3 pre-release if you want to try it out.
Just upgraded to beta-3, and
1) The old GetSrcSetUrls(image, width, height, ratio) does not work anymore - which is nice, as it forces you to change the obsolete code
2) The new format, GetSrcSetUrls(image, ratio) works as expected
Thanks for the update!
Great! Yes whilst we are in beta we can change stuff like this as long as it's for the better. Many thanks for the valuable feedback!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted