Title: catch_that_image &amp; advanced custom fields
Last modified: August 21, 2016

---

# catch_that_image & advanced custom fields

 *  [gerbsi](https://wordpress.org/support/users/gerbsi/)
 * (@gerbsi)
 * [13 years ago](https://wordpress.org/support/topic/catch_that_image-advanced-custom-fields/)
 * Hi,
    im using advanced custom fields [http://www.advancedcustomfields.com](http://www.advancedcustomfields.com)
   to display images, Im using a repeater field. Im using the catch_that_image function
   to get the first image from each post — but id like to grab the first image from
   the ‘bilder_bxslider’ field. Ive benn trying a bit but without luck.
 *     ```
       function catch_that_image() {
         global $post, $posts;
         $first_img = '';
         ob_start();
         ob_end_clean();
         $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
         $first_img = $matches[1][0];
   
       	if( get_field('bilder_bxslider') ):
       		while( has_sub_field('bilder_bxslider') ):
       			$first_img = the_sub_field('bildsnurra');
       		endwhile;
       	endif;
   
         if(empty($first_img)) {
           $first_img = bloginfo( 'template_url' ).'/images/default.jpg'; 
   
         }
         return $first_img;
       }
       ```
   

The topic ‘catch_that_image & advanced custom fields’ is closed to new replies.

## Tags

 * [catch_that_image](https://wordpress.org/support/topic-tag/catch_that_image/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [gerbsi](https://wordpress.org/support/users/gerbsi/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/catch_that_image-advanced-custom-fields/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
