Wordpress cropped thumbnail for RSS feed -


i'm using following generate thumbnail image in wordpress rss feed:

<media:content medium="image" width="128" url="<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->id)); ?>" /> 

how can replace image resized & cropped thumbnail square @ 128x128px?

use wp_get_attachment_image_src instead.

obviously want add error checking, sample usage given scenario:

// wp_get_attachment_image_src requires attachment id, first $attachment_id = get_post_thumbnail_id($post->id); // define desired size array in second option $image_attr = wp_get_attachment_image_src($attachment_id, array(128,128)); // wp_get_attachment_image_src returns array:  // [0] = url, [1] = width, [2] = height, [3] = resized (true / false) // retrieve url array $url = $image_attr[0];  // pass url media element <media:content medium="image" width="128" url="<?php echo $url; ?>" /> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -