Title: cath_image function causing blank pages
Last modified: August 19, 2016

---

# cath_image function causing blank pages

 *  [mediabros](https://wordpress.org/support/users/mediabros/)
 * (@mediabros)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/cath_image-function-causing-blank-pages/)
 * For some reason, the function below in my functions.php in theme folder seems
   to cause blank pages on saving anything in the admin section. Anyone got a idea
   what is causing this problem?
 *     ```
       <?php
       function catch_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(empty($first_img)){
       	$first_img = "/images/default.jpg";
       	}
       	return $first_img;
       	}
       ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [mediabros](https://wordpress.org/support/users/mediabros/)
 * (@mediabros)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/cath_image-function-causing-blank-pages/#post-1429206)
 * i just placed a else on the bottom and now it seems to work, but it couldn’t 
   be that 😮
 * dunno, i am happy
 *     ```
       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(empty($first_img)){
       	$first_img = "/images/default.jpg";
       	} else {
       	return $first_img;
       	}
       	}
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘cath_image function causing blank pages’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [mediabros](https://wordpress.org/support/users/mediabros/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/cath_image-function-causing-blank-pages/#post-1429206)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
