responsive gallery, <a> <img> tags

cryptolect Member Posts: 1
edited July 10 in General


i have a gallery that 1st loads thumbs from <img> and within here there is a srcset. They are transformed correctly according to browser width and i use this url transform for all images in the srcset replacing 256 up to larger sizes:


<div class="grid-item item animated-fast" data-animate-effect="fadeIn">
<a href="full-size-popup.jpg" data-track-content class="image-popup" title="description">
<div class="img-wrap">
sizes="(min-width: 50em) 50em, 100vw"
srcset=",w_256/docs/house.jpg 256w,,w_512/docs/house.jpg 512w,,w_768/docs/house.jpg 768w,,w_1024/docs/house.jpg 1024w,,w_1280/docs/house.jpg 1280w"
alt="Responsive house" />
<div class="text-wrap">
<div class="text-inner popup">

When clicking on a thumb for enlargement, what URL and transform do i need for full-size-popup.jpg in <a href= ?

i don't want an additional wasted request when clicking on the thumb for enlargement and i can't find much on scrset with an a href - the resultant pop-up should be sized appropriately too.

or is there a better way than using the img srcset, like using shrinkwrap.js or client-hints?



  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 141 admin


    In the case that you want to use a single delivery for all the HTML tags of your application, you can use JavaScript to manage the updating of the displaying <img> tag.

    Also, use the onClick event attribute to load a function that returns a false - i.e., in order not to launch the GET request of its href source.

    For example:

    <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <a href="" class="image-popup" title="Nimbuses" onclick='return showImage(this)' > <img id="imageSource1" src=",w_1500/v1720355667/img_1_yzw5dk.jpg" style="width: 200px; height: 133px" /> </a> <br/> <img src="" id='selectedImage' style="width: 500px; height: 400px;" /> <script type='text/javascript'> function showImage(item) { const img_target = document.querySelector('#selectedImage'); img_target.src = document.querySelector('#imageSource1').src; return false; }</script>

    Hope this helps. Please let me know if you have any further questions.

    Best regards,

    Helpful Links For You
    💬 Share questions, connect with other users in our Cloudinary Community forums and Discord server!
    🧑‍🎓 Join our Cloudinary Academy for free courses, workshops and other educational resources.
    📄 Read our documentation for in-depth details on Cloudinary product features and capabilities
    📰 Check out the Cloudinary blog for the latest company news and insights