A specialist in WordPress and Content Management Systems for Business Websites and eCommerce Solutions.
Read more »
Check out my most recent project →
Here’s a quick and easy way to update image sizes on the fly directly in your Wordpress posts. Add this code into your functions.php file in your theme. Then make sure you insert timthumb.php in the root of your theme directory. Next create a fully writable directory named ‘cache’ and place that in your theme root directory.
Now inside your posts just wrap an image URL with the img shortcode. Add height, width, alt, and class to it for more flexibility.
1 2 3 4 5 6 7 8 9 10 11 12 | // Image resize in content // To Use: [img w=600 h=200 class=alignleft alt=My Photo]http://mysite.com/photo.jpg[/img] function timmyimg($atts, $content = null) { extract(shortcode_atts(array( 'w' => '600', 'h' => '250', 'class' => 'alignnone', 'alt' => '' ), $atts)); return "<img src='". get_bloginfo('template_directory') . "/timthumb.php?src=".$content."&w=".$w."&h=".$h."' alt=".$alt." class='wp-post-img ".$class."' />"; } add_shortcode('img', 'timmyimg'); |
Occasionally you’ll need to fetch a posts image outside of the loop.
1 2 3 4 5 6 | <?php $thumb = get_post_meta($post->ID,'_thumbnail_id',false); $thumb = wp_get_attachment_image_src($thumb[0], false); $thumb = $thumb[0];?> <img src="<?php echo $thumb; ?>" alt="" /> |
Combine this with the Timthumb script for control over image size.
This will output the URL to an image with the size predefined by ‘post-thumbnail’ in your functions file when registering the functionality for post images.
1 2 3 4 5 | <?php $thumb = get_post_meta($post->ID,'_thumbnail_id',false); $thumb = wp_get_attachment_image_src($thumb[0], 'my-custom-size', false); $thumb = $thumb[0]; echo $thumb; ?> |
The above code is referencing ‘my-custom-size’, which we can see below as being 405×180. Typically it is not advised to use these predefined sizes as it will overload your uploads directory with additional sizes, and it puts strain on your server when uploading images. Better to use the above method with the Timthumb script to get an exact image size, while making use of image caching.
1 2 3 4 5 | if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9 add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 50, 50, true ); // Normal post thumbnails add_image_size( 'my-custom-size', 405, 180, true ); } |
As a designer I find inspiration for color schemes from all over. From architecture, nature, to paintings and photographs. I’ve driven by houses with a great color scheme and thought to myself “That would make a great color scheme for a website!”.
Using Photoshop’s Filter > Pixelate > Mosaic, we can grab a photograph and find a great scheme from it! Hover the below photos to see the scheme they produce at 65 cell size. Photographs with a wide array of colors will work best.
It is a great idea to have a Facebook fan page for your company, club or organization.
This is a minor hack of the Fotobook plugin (Version 3.1.8) for WordPress by Aaron Harp. Fotobook is originally meant to apply your personal photo albums into WordPress, but we’re going to make one small code tweak to instead pull the albums from the fan page that we administer.
After installing the plugin, go ahead and activate it and grant the permissions to your Facebook account.
Next, visit your Facebook fan page, and click into an album so you’re viewing all photos in one particular album. In the address bar you’ll see a &id=123123123. Copy that ID number.

In the plugin directory open the fotobook.php file and head down to line 243 and look for this code.
$uid = $session['uid'];
Swap that code for this
//$uid = $session['uid'];
$uid = 123123123;
With the 123123123 being the ID code for your fan page.
If you have a custom URL set for your fan page you might notice that the album photos are not showing. To correct that move down around line 809 in fotobook.php and look for:
if(!is_numeric($id)) return false;
And code it out of use by adding // in front so that it now looks like
//if(!is_numeric($id)) return false;
Back in the plugin administration page, go ahead and import your albums. And you should be good to go!
With a thanks to B. Thibault in the forums at the Fotobook Application Page.
I recently noticed that a particular post had built up about 10 or 15 revisions for it. I started thinking that of all the posts I have, there have to be quite a few revisions and therefore are creating a hefty sized table in my database. This was run on my WP 2.8, but should work for 2.6 and up.
Here is a solution to prevent revisions from being created, as well as removing all revisions from your database.
Open wp-config.php and add this to the very bottom of the file, before the php closing tag.
define('WP_POST_REVISIONS', false);
This completely turns off any revision creation. If you’d like to restrict revision creation to a set amount per post, you can change ‘false’ for the number of revisions you’d like stored.
Open up your database in phpmyadmin and run this SQL Query.
DELETE FROM wp_posts WHERE post_type = "revision";
And now you’ll have a more tidy database.