I am trying to fetch a full size Featured Image (or first image) of the post to appear within my RSS feed. See here
I am using the following code
function firstImg( $post ) {
$matches = array();
$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
if ( isset( $matches[1][0] ) ) {
$first_img = $matches[1][0];
}
if ( empty( $first_img ) ) {
return '';
}
return $first_img;
}
add_filter('the_excerpt_rss', 'firstImg');
However, this is only fetching a 200x200 thumbnail size of the image. I want to use the full size which is 600px width.
What's missing in the code?
Thanks
$post
global variable. Also, you can first check if any featured image is available to fetch, if no featured images, pull the first found image.