[wp-trac] [WordPress Trac] #15311: dynamic image resize (on the fly) using already available functions
WordPress Trac
wp-trac at lists.automattic.com
Wed Jun 13 18:39:43 UTC 2012
#15311: dynamic image resize (on the fly) using already available functions
--------------------------+-----------------------------
Reporter: vteixeira | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Media | Version: 3.1
Severity: normal | Resolution:
Keywords: dev-feedback |
--------------------------+-----------------------------
Comment (by daltonrooney):
Thanks so much to Victor, this feature is something I've really been
looking for in WordPress. I did find a small bug and hopefully a
satisfactory solution. The cropped and non-cropped images are both created
with the same dimensions, so if the cropped image already exists and you
try to specify the non-cropped image instead, the cropped image is still
returned. My solution is to calculate the final dimensions of the image
earlier on.
Just before this:
{{{
$cropped_img_path = $no_ext_path.'-'.$width.'x'.$height.$extension;
}}}
Add this:
{{{
/* Calculate the eventual height and width for accurate file name */
if ( $crop == false ) {
$proportional_size = wp_constrain_dimensions( $image_src[1],
$image_src[2], $width, $height );
$width = $proportional_size[0];
$height = $proportional_size[1];
}
$cropped_img_path = $no_ext_path.'-'.$width.'x'.$height.$extension;
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15311#comment:49>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list