Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…y-Posts into ottadvantage-master
  • Loading branch information
picandocodigo committed Nov 28, 2015
2 parents adbb008 + 581bdd0 commit 0527bd1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/lcp-thumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ public function get_thumbnail($single, $thumbnail, $thumbnail_size, $lcp_thumb_c
);
$lcp_thumbnail .= '</a>';
}
else { // if thumbnail is requested but not found as featured image, grab first image in the content of the
if (preg_match('~<img[^>]*src\s?=\s?[\'"]([^\'"]*)~i',get_the_content(), $imgMatches)) {
$lcp_thumbnail = '<a href="' . esc_url(get_permalink($single->ID)) .
'" title="' . esc_attr($single->post_title) . '">';

$lcp_thumbnail .= '<img src="' . esc_url($imgMatches[1]) . '" ';
if ( $lcp_thumb_class != null ) { // thumbnail class passed as parameter to shortcode
$lcp_thumbnail .= 'class="' . $lcp_thumb_class . '" ';
}
else { // Otherwise, use this class name
$lcp_thumbnail .= 'class="lcp_thumbnail" ';
}
$lcp_thumbnail .= ' /></a>';
}
}
} else {
# Check for a YouTube video thumbnail
$lcp_thumbnail = $this->check_youtube_thumbnail($single->content);
Expand Down

0 comments on commit 0527bd1

Please sign in to comment.