Created
May 2, 2014 11:33
-
-
Save marcobarbosa/2eca476e098c28ea63ef to your computer and use it in GitHub Desktop.
Example of using responsive-io with Wordpress featured images
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 | |
// Get our featured image contents | |
$thumb_id = get_post_thumbnail_id( $post->ID ); | |
$thumb_src = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); | |
$thumb_alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true); | |
// Make sure we do have an 'alt' attribute set | |
if(empty($thumb_alt)) $thumb_alt = get_the_title(); | |
// Make it responsive-io ready | |
echo '<img data-src="'.$thumb_src.'" class="attachment-post-thumbnail wp-post-image" alt="'.$thumb_alt.'">'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment