/ Published in: PHP
This post will show you how to make your theme generate thumbnails automatically, based on your post’s first image. Uses timthumb to resize
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // retreives image from the post function getImage($num) { global $more; $more = 1; $content = get_the_content(); $start = 0; for($i=1;$i<=$count;$i++) { $image[$i] = $postOutput; $start=$imgEnd+1; } $more = 0; } //retreive image ends ?> <!--thumnailcode--> <div class="thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php getImage('1'); ?>&w=150&h=150&zc=1"> </a> </div> <!--css--> .thumbnail a:link, .thumbnail a:visited {display:block; float:left; padding:5px; background:#e2e2e2; width:150px; height:150px; margin:5px 5px 0 0;} .thumbnail a:hover, .thumbnail a:active {background:#C4C4C4;}
URL: http://www.problogdesign.com/wordpress/automatic-wordpress-thumbnail-without-custom-field/