Created
December 18, 2012 03:39
-
-
Save turboclaw/4324786 to your computer and use it in GitHub Desktop.
This example will look for the first image in a post, and, if there is one, will display a 75 x 75 pixel thumbnail of it. You can pass an array with width and height, or a size keyword (see here: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image).
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 | |
$images = get_children('post_parent='.$post->ID.'&post_type=attachment&post_mime_type=image&numberposts=1&order=ASC'); | |
if(!empty($images)){ | |
echo wp_get_attachment_image(reset($images)->ID, array(75,75)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment