WordPress.org

Make WordPress Core

Changeset 25744


Ignore:
Timestamp:
10/09/2013 07:06:56 PM (7 years ago)
Author:
nacin
Message:

Make sure when resizing an image according to ratio we do not end up with a zero-pixel width or height.

props plocha.
fixes #25038.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image-edit.php

    r24562 r25744  
    468468
    469469    $ratio = _image_get_preview_ratio( $w, $h );
    470     $w2 = $w * $ratio;
    471     $h2 = $h * $ratio;
     470    $w2 = max ( 1, $w * $ratio );
     471    $h2 = max ( 1, $h * $ratio );
    472472
    473473    if ( is_wp_error( $img->resize( $w2, $h2 ) ) )
  • trunk/src/wp-includes/media.php

    r25665 r25744  
    285285        $ratio = $larger_ratio;
    286286
    287     $w = intval( $current_width  * $ratio );
    288     $h = intval( $current_height * $ratio );
     287    // Very small dimensions may result in 0, 1 should be the minimum.
     288    $w = max ( 1, intval( $current_width  * $ratio ) );
     289    $h = max ( 1, intval( $current_height * $ratio ) );
    289290
    290291    // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short
Note: See TracChangeset for help on using the changeset viewer.