Advertisement
Pierrrrre

Untitled

Jan 10th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // image grabber function
  2. function pbt_resize($w,$h,$class='alignleft',$showlink=true) {
  3. global $more, $post;
  4. $title = the_title_attribute('echo=0');
  5. if($showlink) {
  6. $link = "<a href='".get_permalink()."' title='$title'>";
  7. $linkend = "</a>";
  8. } else {
  9. $link ="";
  10. $linkend="";
  11. }
  12. $more = 1;
  13. $content = get_the_content();
  14. $pattern = '/<img[^>]+src[\\s=\'"]';
  15. $pattern .= '+([^"\'>\\s]+)/is';
  16. $more = 0;
  17. if(preg_match($pattern,$content,$match)) {
  18. $theImage = "$link<img src=\"$match[1]\" class=\"$class\" alt=\"$title\" width=\"$w\" height=\"$h\" />$linkend\n\n";
  19. return $theImage;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement