Skip to content

Instantly share code, notes, and snippets.

@miklb
Last active January 1, 2016 13:49
Show Gist options
  • Save miklb/8154112 to your computer and use it in GitHub Desktop.
Save miklb/8154112 to your computer and use it in GitHub Desktop.
public function filter_post_featuredimage_image($featuredimage_image, $post)
{
if ($post->content_type == Post::type('entry')) {
if (!empty($post->info->featuredimage_image)) {
return $post->info->featuredimage_image;
}
preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->content, $matches);
if (sizeof($matches[1]) > 0) {
return $matches [1] [0];
}
}
return $featuredimage_image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment