• Resolved scottnath

    (@scottnath)


    Hi there,

    Because I use WordPress’ post-thumbnails feature I’ve already chosen the image that I would like to represent a given post. Because of that, I made a modification to your code to first check if there is a post-thumbnail, and if not, to then choose an image from the post. It’d be great to have something along these lines in a future release.

    // Check if there is a post-thumbnail
                    $postthumbnail = get_the_post_thumbnail( $posts[$index]->ID );
                    if($postthumbnail){
    	                // use the post-thumbnail
    	                preg_match_all('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i', $postthumbnail, $matches);
                    }else{
    	                // Get all images from post's body
    	                preg_match_all('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i', $posts[$index]->post_content, $matches);
                    }

    Thanks for writing this, exactly what I was looking for.

    -scott

    http://wordpress.org/extend/plugins/calendar-archives/

  • The topic ‘[Plugin: Calendar Archives] Modified: using Post-Thumbnail first if it exists.’ is closed to new replies.