Guest User

função para gerar miniaturas no wp

a guest
Nov 7th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. /*-----------------------------*/
  2.  
  3.  
  4. // retreives image from the post
  5. function getImage($num) {
  6. global $more;
  7. $more = 1;
  8. $content = get_the_content();
  9. $count = substr_count($content, '<img');
  10. $start = 0;
  11. for($i=1;$i<=$count;$i++) {
  12. $imgBeg = strpos($content, '<img', $start);
  13. $post = substr($content, $imgBeg);
  14. $imgEnd = strpos($post, '>');
  15. $postOutput = substr($post, 0, $imgEnd+1);
  16. $image[$i] = $postOutput;
  17. $start=$imgEnd+1;  
  18.  
  19. $cleanF = strpos($image[$num],'src="')+5;
  20. $cleanB = strpos($image[$num],'"',$cleanF)-$cleanF;
  21. $imgThumb = substr($image[$num],$cleanF,$cleanB);
  22.  
  23. }
  24. if(stristr($image[$num],'<img')) { echo $imgThumb; }
  25. $more = 0;
  26. }
  27. //retreive image ends
Advertisement
Add Comment
Please, Sign In to add comment