Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: Pierrrrre on Jan 10th, 2012  |  syntax: None  |  size: 0.61 KB  |  views: 75  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data