Guest User

Untitled

a guest
Jun 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2. function catch_that_image()
  3. {
  4.      //Gets the link to the first image of the post
  5.      global $post, $posts;
  6.      $first_img = '';
  7.      ob_start();
  8.      ob_end_clean();
  9.      $output = preg_match_all('//i', $post->post_content, $matches);
  10.      $first_img = $matches [1] [0];
  11.      if(empty($first_img))
  12.      {
  13.           $first_img = "/images/default.jpg";
  14.      }
  15.      //Converts the link to the link of the thumbnail of that image
  16.      $explodepoint = explode(".",$first_img);
  17.      $count = count($explodepoint);
  18.      $size = "-150x150";
  19.      $explodepoint[$count-2]= $explodepoint[$count-2]."".$size;
  20.      $thumb_img = implode(".",$explodepoint);
  21.      echo $thumb_img;
  22. }
  23. ?>
Add Comment
Please, Sign In to add comment