Last active
February 27, 2019 21:06
-
-
Save eclarrrk/bf1d71b82d59d5daeb9fb7c6dfd12606 to your computer and use it in GitHub Desktop.
Snippet for creating responsive images while controlling scrset values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$imageID = get_sub_field('img_id'); // ACF should return image ID | |
$size = 'full'; | |
?> | |
<img | |
class="jetpack-lazy-image" | |
src="<?php echo wp_get_attachment_image_url( $imageID, '$size' ) ?>" | |
srcset="<?php echo wp_get_attachment_image_srcset( $imageID, '$size' ) ?>" | |
sizes=" (min-width: 1400px) 800px, | |
(min-width: 860px) 60vw, | |
100vw" | |
alt="<?php echo get_post_meta($imageID, '_wp_attachment_image_alt', true); ?>" | |
/> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment