Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Picture Element
<?php //different sizes ?>
<?php $large_image_urlLarge = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogLarge' ); ?>
<?php $large_image_urlMedium = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogMedium' ); ?>
<?php $large_image_urlSmall = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogSmall' ); ?>
<?php //title == alt ?>
<?php $title = get_post(get_post_thumbnail_id())->post_title; //The Title ?>
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="<?php echo $large_image_urlLarge[0];?>" media="(min-width: 912px)">
<source srcset="<?php echo $large_image_urlMedium[0];?>" media="(min-width: 400px)">
<source srcset="<?php echo $large_image_urlSmall[0];?>">
<!--[if IE 9]></video><![endif]-->
<img srcset="<?php echo $large_image_urlLarge[0];?>" alt="<?php echo $title; ?>">
</picture>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment