Skip to content

Instantly share code, notes, and snippets.

@andrescifuentesr
Created September 18, 2014 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrescifuentesr/38bdc173ff323d9e0035 to your computer and use it in GitHub Desktop.
Save andrescifuentesr/38bdc173ff323d9e0035 to your computer and use it in GitHub Desktop.
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