Automatically resize pictures on your WordPress blog

October 16, 2009 at 9:03 am

While it is very cool to add pictures to your blog posts, dealing with image sizes can be a bit tricky sometimes, especially if you have no skills about image resizing. The solution to this problem is to use Timthumb and WordPress shortcode API. Just read on to find out!

First, note that this code use TimThumb to resize pictures. This recipe explain how to install TimThumb on your WordPress blog.

Let’s start by creating the shortcode. Just paste the code below into your functions.php file.

function imageresizer( $atts, $content = null ) {
	return '<img src="/timthumb/timthumb.php?src='.$content.'&w=590" alt="" />';
}

add_shortcode('img', 'imageresizer');

Then, you can use the following syntax to add an automatically resized image to your blog post:

[img]http://www.yoursite.com/yourimage.jpg[/img]

That’s all. Nice, isn’t it? By the way, I just published a post on one of my other blogs about Ten WordPress plugins to monetize your blog, you might want to check it out!

Source : http://www.catswhocode.com/blog/10-tricks-to-make-your-wordpress-theme-stand-out – By Alex Denning.