Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel 11 posts 91 karma points
    Dec 30, 2017 @ 18:06
    Daniel
    0

    Slimsy 2.0 Sample question

    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:

    • I understand the 0 is to keep the image ratio, but why is the width set at 1920, since the image is responsive?
    • What is the usage of the 270, 161 in the data-src?

    Also, can someone point me to a good explanation of the data-srcset and data-src attributes?

    Any insides appreciated.

    Daniel

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Dec 31, 2017 @ 11:30
    Jeavon Leopold
    100

    Hi Daniel,

    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.

    Jeavon

  • Daniel 11 posts 91 karma points
    Jan 04, 2018 @ 12:33
    Daniel
    0

    Hi Jeavon, 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...

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Jan 04, 2018 @ 13:21
    Jeavon Leopold
    0

    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.

  • Daniel 11 posts 91 karma points
    Feb 02, 2018 @ 08:57
    Daniel
    0

    Hi Jeavon, 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!

    Daniel

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Feb 02, 2018 @ 09:36
    Jeavon Leopold
    0

    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!

Please Sign in or register to post replies

Write your reply to:

Draft