web_dor_catch_that_image

The WordPress Core web dor catch that image function.

Description

web_dor_catch_that_image(); 

Usage

  1. if ( !function_exists( 'web_dor_catch_that_image' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = web_dor_catch_that_image(); 
  7.  

Defined (1)

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

/functions.php  
  1. function web_dor_catch_that_image() 
  2.  
  3. global $post, $posts; 
  4.  
  5. $first_img = ''; 
  6. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); 
  7. if(isset($matches [1] [0])) {  
  8. $first_img = $matches [1] [0]; 
  9. if (empty($first_img)) { 
  10.  
  11. //Defines a default image 
  12.  
  13. $first_img = get_template_directory_uri() . "/images/default.jpg"; 
  14.  
  15.  
  16. return $first_img;