My favorites | Sign in
Project Logo
                
Search
for
Updated Mar 04, 2008 by Alakhnor
TricksAndHints  
Highlights on some functions and usage of Post-Thumb.

Several sizes of thumbnails

It's common to display a page on which there are sevral different sizes of thumbnails. In this case, Post-Thumb will create the first one and will use it for each display of the same picture. The first way to have different sizes is to save thumbnails in different folders. This is done by using the "subfolder" parameter. Example:

<?php $i=1; ?>
<?php while (have_posts()) : the_post(); ?>
	<?php if ($i==1) : ?>
		<?php the_thumb('subfolder=feature&width=300&height=225&keepratio=1'); ?>
	<?php else :
		<?php the_thumb('subfolder=loop&width=80&height=60&keepratio=0); ?>
	<?php endif; ?>
	<?php $i++;
<?php endwhile; ?>

This will save the "big" thumbnails (300x225) in folder "feature" and the "small" (80x60) in "loop" folder.

Using post-thumb with Mimbo theme

Mimbo home page (index.php) uses several display of thumbnails. However, they have to be manage manually. Using Post-Thumb can ease it.

    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/<?php
// this is where the Lead Story image gets printed
	$values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="" id="leadpic" /></a>

You can replace this with a simple call to the_thumb:

<?php the_thumb('link=p&subfolder=home&width=nnn&height=nnn'); ?>

just choose width and height values there. You can also choose to keep original picture ratio (keepratio=1) or to have a fixed ratio (keepratio=0).

Advanced excerpt

It's common to associate a thumbnail to an excerpt. However, WordPress standard excerpt is rather limited. So, Post-Thumb comes with its own excerpt function: get_pt_excerpt To use it, just replace the usual call:

<?php the_excerpt() ?>

with:

<?php echo get_pt_excerpt(); ?>

Now, you can use its parameter to adjust it. If you want to obtain this: "Lorem ipsum dolor sit amet, consectetuer adipisci elit. Desistemus sed uti praeterea esse dedecora si metu, probarem asperiores, reque omni audire, posset est quam ex amicitiae nulli, nec nullo fortunae ut iudicari aut voluptatis facete tam, et non hostem, atque...More" Then the function should be:

<?php echo get_pt_excerpt("words=40&showdots=1&link&moretext=[Read More]"); ?>

Which will show 40 words, add the link at the end of the excerpt, add '...' between the excerpt and the link and will attached the link to More.


Comment by nate.ricklin, Apr 15, 2008

the first example here gives a parse error.


Sign in to add a comment
Hosted by Google Code