Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. function primeira_imagem() {
  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.    
  8.     if($output >= 1) {
  9.         $first_img = $matches[1][0];
  10.     }
  11.  
  12.     return $first_img;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement