WordPress.org

Plugin Directory

Changeset 627834


Ignore:
Timestamp:
11/20/12 18:55:52 (17 months ago)
Author:
ethitter
Message:

Photon update

Expands upon changes made in r622713.

If a isn't available but a height is, simply use the h API function rather than setting an artificially-large value for width and using fit. Now, fit is only used if a height and are available, but no explicit width could be determined.

With these changes, resize, w, and h are used in the majority of cases.

Props westi and mkoenig.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/modules/photon.php

    r627731 r627834  
    134134                } 
    135135 
    136                 // Set a width if none is found and height is available, either $content_width or a very large value 
    137                 // Large value is used so as to not unnecessarily constrain image when passed to Photon 
    138                 if ( false === $width && false !== $height ) { 
    139                     $width = is_numeric( $content_width ) ? (int) $content_width : 9999; 
    140                     $transform = 'fit'; 
     136                // Set a width if none is found and $content_width is available 
     137                // If width is set in this manner and height is available, use `fit` instead of `resize` to prevent skewing 
     138                if ( false === $width && is_numeric( $content_width ) ) { 
     139                    $width = (int) $content_width; 
     140 
     141                    if ( false !== $height ) 
     142                        $transform = 'fit'; 
    141143                } 
    142  
    143                 // As a last resort, ensure that image won't be larger than $content_width if it is set. 
    144                 if ( false === $width && is_numeric( $content_width ) ) 
    145                     $width = (int) $content_width; 
    146144 
    147145                // Build URL, first removing WP's resized string so we pass the original image to Photon 
Note: See TracChangeset for help on using the changeset viewer.