Last active
April 23, 2019 10:17
-
-
Save thetwopct/fba73ce5141d2c41c967d279974b6714 to your computer and use it in GitHub Desktop.
ACF Responsive Images (srcset)
This file contains hidden or 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 | |
$img = the_sub_field( 'image' ); // or get_field ACF - make sure field is set to ID | |
$size = 'home-hero'; // thumbnail size | |
$src = wp_get_attachment_image_src( $img, $size ); | |
$srcset = wp_get_attachment_image_srcset( $img, $size ); | |
?> | |
<img class="pillar-image" | |
src="<?php echo esc_url( $src[0] ); ?>" | |
srcset="<?php echo esc_attr( $srcset ); ?>" | |
sizes="(max-width: 640px) 640px, (max-width: 1024px) 1024px, 1600px" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment