0

I am using the following code in my functions.php and it shows the thumbnail properly in my mailchimp's campaign test email ...

function dn_add_rss_image() {
global $post;

$output = '';
if ( has_post_thumbnail( $post->ID ) ) {
    $thumbnail_ID = get_post_thumbnail_id( $post->ID );
    $thumbnail = wp_get_attachment_image_src( $thumbnail_ID, 'thumbnail' );

    $output .= '<media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" type="image/jpeg"';
    $output .= ' url="'. $thumbnail[0] .'"';
    $output .= ' width="'. $thumbnail[1] .'"';
    $output .= ' height="'. $thumbnail[2] .'"';
    $output .= ' />';
  }
  echo $output;
}
add_action( 'rss2_item', 'dn_add_rss_image' );

but I'd like to show large size images in my campaign since the thumbnail looks bad and the image is cut. Please help me modify the code above to show full featured images with the ability to change the width.

Any help is highly appreciated.

1

$thumbnail = wp_get_attachment_image_src( $thumbnail_ID, 'full' );

https://codex.wordpress.org/Post_Thumbnails

|improve this answer|||||
  • Thank you Michael. That worked like a charm! Can you please help me with the max width as well? I am using that modified code you gave me but the image is pretty big. It'd be great if the max width can be restricted to 560px (which is the recommended width for email templates) – Naser Mohd Baig Sep 19 '18 at 11:37
  • Did you check the link in my answer? You can register custom image sizes. – Michael Sep 19 '18 at 13:13
  • Thanks again Micheal. I didn't check that earlier, but did now and used array(560,9999) instead of using 'full' and it worked. – Naser Mohd Baig Sep 19 '18 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.