Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function catch_that_image()
- {
- //Gets the link to the first image of the post
- global $post, $posts;
- $first_img = '';
- ob_start();
- ob_end_clean();
- $output = preg_match_all('//i', $post->post_content, $matches);
- $first_img = $matches [1] [0];
- if(empty($first_img))
- {
- $first_img = "/images/default.jpg";
- }
- //Converts the link to the link of the thumbnail of that image
- $explodepoint = explode(".",$first_img);
- $count = count($explodepoint);
- $size = "-150x150";
- $explodepoint[$count-2]= $explodepoint[$count-2]."".$size;
- $thumb_img = implode(".",$explodepoint);
- echo $thumb_img;
- }
- ?>
Add Comment
Please, Sign In to add comment