Advertisement
simonwheatley

Possible uses of new WP RSS Images plugin

May 2nd, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2.  
  3. // These functions could go into the functions.php in your theme, or form
  4. // part of another plugin.
  5.  
  6. /**
  7.  * Hooks the WP wp_rss_image_size filter
  8.  *
  9.  * @param  
  10.  * @return void
  11.  **/
  12. function sw_wp_rss_image_size( $size ) {
  13.     $size = 'large-feature';
  14.     return $size;
  15. }
  16. add_filter( 'wp_rss_image_size', 'sw_wp_rss_image_size' );
  17.  
  18. /**
  19.  * Hooks the WP wp_rss_image_alternative filter
  20.  *
  21.  * @param  
  22.  * @return void
  23.  **/
  24. function sw_wp_rss_image_alternative( $false, $post_id ) {
  25.     $post = get_post( $post_id );
  26.     $img_url = $false;
  27.     if ( $thumbnail_id = get_post_thumbnail_id( $post->ID ) ) {
  28.         $img = wp_get_attachment_image_src( $thumbnail_id, 'small-feature' );
  29.         $img_url = $img[ 0 ];
  30.     }
  31.     return $img_url;
  32. }
  33. add_filter( 'wp_rss_image_alternative', 'sw_wp_rss_image_alternative', 10, 2 );
  34.  
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement