Skip to main content

using client hints to return dynamic full screen images for different viewport sizes

Comments

1 comment

  • Marissa Masangcay

    Hi Simon,

    Currently we only support automatically calculating the width. So you can use Client Hints to display a 100% width like so:

    <meta http-equiv="Accept-CH" content="DPR, Width">
    
    […snip…]
    
    <img sizes="100vw"
         src="https://res.cloudinary.com/demo/w_auto/bike.jpg" 
         alt="Smiling girl with a bike." />

    You can find this particular example and more information about Client Hints in this article:
    https://cloudinary.com/blog/automatic_responsive_images_with_client_hints

    As a workaround for obtaining the height you can use javascript to detect the containing div’s size and then use that as the h_ value for the URL.

    Hope this helps!

    0

Post is closed for comments.