groups

Link to this snippet:


Download to Code Collector

language: PHP
licence: Other

Auto-Resize Images Using TimThumb And WordPress Shortcodes

options: send to code collectorview all maeghan's snippets
//The first thing to do is create the shortcode. Paste the following code in your functions.php file

function imageresizer( $atts, $content = null ) {
	return '<img src="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2009/10//timthumb/timthumb.php?src='.$content.'&w=590" alt="" />';
}

add_shortcode('img', 'imageresizer');


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

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