• Hi, I am using Zurb Foundation as my framework. I would like to get the width and height output in my src as I have seen from other examples. My current output:

    <img class="" src="https://xxx/wp-content/uploads/2015/04/MG-8100.jpg" srcset="https://xxx/wp-content/uploads/2015/04/MG-8100-640x427.jpg 640w, https://xxx/wp-content/uploads/2015/04/MG-8100-780x520.jpg 780w, https://xxx/wp-content/uploads/2015/04/MG-8100.jpg 1200w" alt="">

    My current code is:

    <img src="<?php echo $image['url']; ?>" <?php echo tevkori_get_srcset_string( $the_id, 'large' ); ?> alt="<?php echo $image['alt']; ?>" />

    I even tried using the sizes option:

    <img src="<?php echo $image['url']; ?>" <?php echo tevkori_get_srcset_string( $the_id, 'large' ); ?> sizes="<?php echo tevkori_get_sizes($the_id, 'large'); ?>" alt="<?php echo $image['alt']; ?>" />

    Thank you!!! Love the plugin, great work.

    https://www.ads-software.com/plugins/ricg-responsive-images/

Viewing 4 replies - 1 through 4 (of 4 total)
  • armando_e,

    I’m not one of the developers, and cannot answer your question (you’ll have to wait for someone else to do that for you). But since you know how to code, I thought I’d give you three links that you might find useful:

    1. This Plugin’s Merge Proposal for WordPress Core: https://make.www.ads-software.com/core/2015/09/30/responsive-images-merge-proposal/.

    2. The Initial Core Patch Offered: https://core.trac.www.ads-software.com/ticket/33641.

    3. The Initial Core Commit which will show up in WordPress 4.4:
    https://core.trac.www.ads-software.com/changeset/34855.

    With your skills, you might be able to help contribute to the core merge or comment on its continued development as a plugin until that time.

    Plugin Contributor Joe McGill

    (@joemcgill)

    Hi armando_e,

    The height and width parameters that you see in other examples are usually coming from WordPress, and not from our plugin. You can manually add those attributes yourself, or you can use a function like wp_get_attachment_image_src() to get the image url, height, and width before creating your image tag.

    That said, if you use wp_get_attachement_image( $the_id, 'large' ) you’ll get the full img element including srcset and sizes without the need to write out any of the HTML yourself.

    Hope this helps.

    Thread Starter armando_e

    (@armando_e)

    Thank you both for this information. Joe, if I get the width/height using wp_get_attachment_image_src(), will that return the full largest size or will it return the current size (like medium)? My goal is to implement this with Masonry and Lazy Load, which can trigger the layout if each element has a width and height, otherwise, I would have to wait for images to load before i can fire Masonry/Lazy Loading.

    Thanks again for your speedy support replies and wonderful plugin.

    Plugin Contributor Joe McGill

    (@joemcgill)

    Hey Armando,

    Sorry for the delay. The function you mention, wp_get_attachment_image_src() will still return the current size. For lazy loading, you may want to take a look at aFarkas lazysizes code: https://github.com/aFarkas/lazysizes

    He has a WordPress plugin as well, but I think it may be outdated.

    Joe

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Width and Height’ is closed to new replies.