How To Integrate Images Shortcode with TimTumb


Sponsored Links




Every WordPress Developer has seen that TimTumb is wonderful script, This script is better handle to resize image on the fly and display it what ever size we want and we need. Let’s me show you How To Integrate Images Shortcode with TimTumb. The idea is simple. We will use the power of TimThumb and generated better thumbnail and added in our content using shorcode. We got this tricks from Free WordPress Themes designer.

Images Shortcode with TimThumb - Lucy Pinder Nuts August 2010 Photo

Images Shortcode with TimThumb - Lucy Pinder Nuts August 2010 Photo


To began this trikcs, open your functions.php we need to added extra code and functions on it.

// Image resize in content
function timmyimg($atts, $content = null) {
	extract(shortcode_atts(array(
		'w' => '460',
		'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');

After you completed it, Download latest TimThumb script (if you have a problem with TimThumb you can try Tips How To Fix TimThumb) and upload it on your current directory. To use this code is simple. Just write down on your post content like this example

[img w=460 h=200 class=alignleft alt=My Photo]http://mysite.com/photo.jpg[/img]

That’s it, you can use this shortcode what ever you want and how many you like ;)

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net


One Response to How To Integrate Images Shortcode with TimTumb

  1. Pingback: How To Integrate Google Font Directory on WordPress Theme | Jhez3R

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>