catch_that_image

The BP Groupblog catch that image function.

Description

catch_that_image(); 

Usage

  1. if ( !function_exists( 'catch_that_image' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-groupblog/themes/p2-buddypress/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = catch_that_image(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/themes/p2-buddypress/functions.php  
  1. function catch_that_image() { 
  2. global $post, $posts; 
  3. $first_img = ''; 
  4. ob_start(); 
  5. ob_end_clean(); 
  6. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); 
  7. $first_img = $matches [1] [0]; 
  8.  
  9. if(empty($first_img)) { //Defines a default image 
  10. $first_img = WP_CONTENT_URL . '/themes/p2-buddypress/groupblog/_inc/i/noimage.jpg'; 
  11. return $first_img;