Advertisement
Guest User

Create A Loop Of Images

a guest
Mar 2nd, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  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 = "/images/default.jpg";
  11.   }
  12.   return $first_img;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement