Title: Replace thumb with first image post
Last modified: August 20, 2016

---

# Replace thumb with first image post

 *  Resolved [flandreau](https://wordpress.org/support/users/flandreau/)
 * (@flandreau)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/)
 * Hi Julio,
 * First thanks for the quick update of this plugin it works perfectly for now.
 * I have a question. Perhaps this is already possible but I can’t figure out how
   it is possible. In my blog all post are starting with an image. testing different“
   related posts” plugins I saw for example the with SEO ALRP that related posts
   come with this first image. With you plugin I just have the wordpress thumb. 
   Is it possible to make in sort that when I choose the display with thumb I have
   my first image post coming instead of the wp thumb?
 * Thanks in advance
 * François
 * [http://wordpress.org/extend/plugins/baw-manual-related-posts/](http://wordpress.org/extend/plugins/baw-manual-related-posts/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Julio Potier](https://wordpress.org/support/users/juliobox/)
 * (@juliobox)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/#post-3167774)
 * Hello
 * yes you can use the “bawmrp_no_thumb” filter, like this:
 *     ```
       function catch_my_first_image( $image, $post_id )
       {
         $_post = get_post( $post_id );
         if( !$_post ) return $image;
         $image = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $_post->post_content, $matches );
         if( isset( $matches[1][0] ) )
           $image = $matches[1][0];
         return $image;
       }
   
       add_filter( 'bawmrp_no_thumb', 'my_own_bawmrp_thumb' );
       function my_own_bawmrp_thumb( $thumb, $post_id )
       {
           return catch_my_first_image( $thumb, $post_id );
       }
       ```
   
 * You can also use the “bawmrp_thumb_size” to change the thumb zize, like this:
   
   add_filter( ‘bawmrp_no_thumb’, ‘my_own_bawmrp_thumb’ );
 *     ```
       function my_own_bawmrp_thumb_size( $sizes )
       {
           return array( '64', '64' ); // only 64px
       }
       ```
   
 * _ps : not tested, just coded here._
 *  Thread Starter [flandreau](https://wordpress.org/support/users/flandreau/)
 * (@flandreau)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/#post-3167775)
 * Many Thanks Julio,
 * last question around this :). I’m not really a strong wordpress user so i’d like
   to know where I must put this code. Is it in the function.php, a plugin file,
   or in any other place?
 * François
 *  Plugin Author [Julio Potier](https://wordpress.org/support/users/juliobox/)
 * (@juliobox)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/#post-3167777)
 * Sorry, copy/paste this in your functions.php from your activated theme folder.
 *  Thread Starter [flandreau](https://wordpress.org/support/users/flandreau/)
 * (@flandreau)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/#post-3167781)
 * ok thank you. I think I must have a problem with my theme because this is not
   working. I’m using a wootheme typebased and for what i have seen in another module
   perhaps I miss some thumb functionnalities
 * François
 *  Thread Starter [flandreau](https://wordpress.org/support/users/flandreau/)
 * (@flandreau)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/#post-3167782)
 * ok I think I have no problem with my theme at the end. I rmeoved plugin cach 
   and now images are broken. When I inspect element I see this:
    `<img src="0" 
   height="100" width="100">` where the image url is replaced by ‘0’ perhaps there
   is a problem in the code you just made ?
 *  Plugin Author [Julio Potier](https://wordpress.org/support/users/juliobox/)
 * (@juliobox)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/#post-3167787)
 * my bad this is:
 * `add_filter( 'bawmrp_no_thumb', 'my_own_bawmrp_thumb', 10, 2 );`
 * and NOT
 * `add_filter( 'bawmrp_no_thumb', 'my_own_bawmrp_thumb' );`

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Replace thumb with first image post’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/baw-manual-related-posts_fefdfd.svg)
 * [Manual Related Posts](https://wordpress.org/plugins/baw-manual-related-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/baw-manual-related-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/baw-manual-related-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/baw-manual-related-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/baw-manual-related-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/baw-manual-related-posts/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Julio Potier](https://wordpress.org/support/users/juliobox/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/replace-thumb-with-first-image-post/#post-3167787)
 * Status: resolved