cristiansans (owner)

Revisions

gist: 80178 Download_button fork
public
Public Clone URL: git://gist.github.com/80178.git
Embed All Files: show embed
automating post image thumbnails #
1
2
3
4
5
6
7
8
9
10
11
12
13
function getImage( $postID, $size = "thumbnail" ) {
    $images = get_children( "post_parent=$postID&post_type=attachment&post_mime_type=image" );
    if ( $images ) {
        foreach( $images as $image_id => $image_infos ) {
            $the_image = wp_get_attachment_image_src( $image_id, $size );
            if ( $the_image ) {
                return $the_image[0];
                break;
            }
        }
    }
    return "";
}