ThumbPress is a little plugin I created to access the power of phpThumb (which is not little!) within my WordPress themes. The fancy thumbnails on my blog’s home page and the header images at the top posts are created on the fly to required size and cached using phpThumb.
The new LivingOS Mu Theme has built in support for this plugin and will use it by default if installed instead of the simpler timthumb script. This theme also has the added benefit of an extra post write panel for setting the custom field settings below.
- unzip and upload into your wp-content/plugins directory
- change the phpThumb security password in phpThumb.config.php (see below)
- make sure the thumbpress/phpthumb/cache folder is writable
- use one of the functions below in your theme somewhere
- use the settings/thumbpress page to edit options or clear cache
Set the security password
ThumbPress uses phpThumb in high security mode. So before you do anything you should change the value of the parameter in phpThumb/phpThumb.config.php
$PHPTHUMB_CONFIG[‘high_security_password’] = “wquy98yw98qye”
This can be anything and you don’t need to remember it. So make it long with lots of different chars.
tp_postimage(with, height, overlay_image, default_image, headerimage?)
This function provides logic and handling of post custom fields to create an <img> tag. Use it to create post thumbs in a loop or on a single post for a header image. The custom fields allow users to turn off the header for selected posts (see below). Returns full <img> tag.
tp_bookthumbs($amount=-1, $link_category = 0, $thumb_w=75, $thumb_h=75, $use_websnapr=0, $overlay_image)
Creates a list of thumbnailed links. It uses the image in the link image field and will if enabled use WebSnapr to create thumbs if image field is blank.
tp_thumbnail($fname, $width = 0, $height = 0, $over = ”)
The function called by above functions for creating fancier thumbnails with an overlay image.
Returns just the url to use in an img src attribute.
The interface to phpThumb
Simply passes src image and phpThumb parameter string to phpThumb. Retunrs url to use in img src attribute.
Post Custom Fields
To use the tp_postimage function add the following custom fields to your posts:
post-image : url of image to be thumbnailed
and these optional fields are for post header images:
post-image-url : image post head image links to (defaults to #)
post-image-title : title given to image link (i.e. when user hovers over image text is usually displayed)
post-image-nohead : if anything other than empty, turns of the post head for this post
Image Filenames and Paths
The source image can be any image url. You can change settings in phpThumb config to prevent images from off site if required. The overlay image parameter is the short filename where all overlay images are in thumbpress/images folder. e.g. “roundedmask.png”
produces thumbnail 280×280 with rounded edge border by combining overlay
produces a header image for a post and processes custom fields
<?php tp_thumbnailburl($yourfilename, 'w=500&h=300&zc=1'); ?>
Access phpThumb direct with your own options string. Just leave the & off the front of the string.
I’ve been using this plugin for a while on my blog without problems, but phpThumb is a complex beast so don’t expect me to answer all your questions. Help may best be found in the livingos forums.