Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // Funzione per mostrare qualunque immagine nel loop
- function getImage($num) {
- global $more;
- $more = 1;
- $link = get_permalink();
- $title = get_the_title ();
- $alt = get_the_title ();
- $content = get_the_content();
- $count = substr_count($content, '<img');
- $start = 0;
- for($i=1;$i<=$count;$i++) {
- $imgBeg = strpos($content, '<img', $start);
- $post = substr($content, $imgBeg);
- $imgEnd = strpos($post, '>');
- $postOutput = substr($post, 0, $imgEnd+1);
- $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '/width="200px" height="200px"/',$postOutput);
- $image[$i] = $postOutput;
- $start=$imgEnd+1;
- }
- if(stristr($image[$num],'<img')) { echo '<a title="'.$title.'" href="'.$link.'">'.$image[$num]."</a>"; }
- $more = 0;
- };?>
- <?php
- function get_post_thumbnail() {
- $files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
- if($files) :
- $keys = array_reverse(array_keys($files));
- $j=0;
- $num = $keys[$j];
- $image=wp_get_attachment_image($num, 'large', false);
- $imagepieces = explode('"', $image);
- $imagepath = $imagepieces[1];
- $thumb=wp_get_attachment_thumb_url($num);
- print $thumb;
- else:
- print "http://www.yourdomain.com/wp-content/uploads/2010/02/default-post-thumb.jpg";
- endif;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement