[wp-trac] [WordPress Trac] #12120: Force Media Image Generation (for thumbnails)
WordPress Trac
wp-trac at lists.automattic.com
Wed Feb 3 17:53:35 UTC 2010
#12120: Force Media Image Generation (for thumbnails)
-------------------------+--------------------------------------------------
Reporter: atow | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Media | Version: 2.9.1
Severity: normal | Keywords: media thumbnail
-------------------------+--------------------------------------------------
It would be very useful to force the generation of a thumbnail images for
uploaded files. With content being syndicated to feeds, e-readers, and
mobile devices, the ability to have a working thumbnail is more important.
For example, if the original image has dimensions of 250x50, and the
default thumbnail size in WP is 150x150, a thumbnail will not be generated
because the 50 height is smaller than the 150 pixel minimum.
The fix would be to include an additional parameter to the
image_resize_dimensions to allow the function the dimensions. A filter
could be applied to allow the user to set which images should force the
generation of a resized image (i.e. to exclude a medium and large image
from being generated for a 250x50 image) by passing in the original
width/height and max width/height.
in wp-includes/media.php
========
function image_resize( $file, $max_w, $max_h, $crop = false, $suffix =
null, $dest_path = null, $jpeg_quality = 90 ) {
...
$force = apply_filters('image_resize_dimensions_force', $orig_w, $orig_h,
$max_w, $max_h);
$dims = image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop,
$force);
========
function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop
= false, $force = false) {
...
// if the resulting image would be the same size or larger we don't want
to resize it
if ( $new_w >= $orig_w && $new_h >= $orig_h && !$force )
return false;
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12120>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list