Adding dynamic image sizes

Dynamic Image Resizing

WordPress offers a lots of (confusing) functions to handle images: Re-sizing, Cropping, etc. But re-sizing images on demand/on the flight is not part of the game. If you’re using TimThumb to bridge this gap, then you’re doing it wrong. Why? Because there are really smart people like Konstantin Kovshenin, who has written a pretty smart draft on how to do this with plain simple WordPress core functions. As he offered it as Gist and pushed to fork it, I jumped in, fixed and extended some parts and made a MU-Plugin out of it.

How to use the shortcode Place

[dynamic_image] in your content. The shortcode has four arguments:
1. src Full path to the image in your upload directory
2. width Integer value
3. height Integer value
4. classes Css classes – separated by a space

How-to use it in your template files

dynamic_image_resize( array(
     // The full path in your upload directory
     'src'     => ''
     // Or the ID
     'src'     => 32
    ,'width'   => 60
    ,'height'  => 100
    ,'classes' => 'some classes to align and style the image'
) );

Read the original article at (Thanks, Konstantin :). VISIT DOWNLOAD You might also want to take a look at my class to handle the WordPress default image generation – I call it a fix, as it offers an easy possibility to handle the WordPress image generation, cropping, adding extra sizes, deactivating built in sizes, etc. Just the way it should imo ever been in core. DOWNLOAD GIST