• 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

    (@mediabros)

    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.