wordpress has a good support for images in general.
to get new image sizes, one would just add some functions like :
add_theme_support( 'post-thumbnails' ); //thumnails
set_post_thumbnail_size( 200, 120, true ); // Normal post thumbnails
add_image_size( 'single-post-thumbnail', 400, 300,False ); // single-post-test
add_image_size( 'tooltip', 100, 100, true ); // Tooltips thumbnail size
/// and so on and so on
my question is :
How can someone make those functions act in a dynamic manner , meaning that those sizes will be calculated on upload ?
for example – If I upload an image of 3000×4000 px – I would like my image sizes to be :
add_image_size( 'half', 50%, 350%, False ); // Half the original
add_image_size( 'third', 30%, 30%, true ); // One Third the original
Is there a way to do that ? where can I hook for that ?
Those image sizes are used registered in many functions –
Can someone think of an Uber-creative way to achieve that ?
Or you could use the filter
image_resize_dimensions
.I have setup a new image with a strange width and height like so
Then used the filter to half the image only when the half image size is being resized
You can use wp_get_attachment_image_src to get downsized images of an attachement, in you case you only need to specify
add_theme_support( 'post-thumbnails' )
in yourfunctions.php
file then in your template do the following: