Make WordPress Core

Ticket #35390: 35390.patch

File 35390.patch, 2.5 KB (added by jaspermdegroot, 9 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 6b0187a..8d3f091 100644
    function image_hwstring( $width, $height ) { 
    155155 *
    156156 * @since 2.5.0
    157157 *
    158  * @param int          $id   Attachment ID for image.
    159  * @param array|string $size Optional. Image size to scale to. Accepts any valid image size,
    160  *                           or an array of width and height values in pixels (in that order).
    161  *                           Default 'medium'.
     158 * @param int          $id        Attachment ID for image.
     159 * @param array|string $size      Optional. Image size to scale to. Accepts any valid image size,
     160 *                                or an array of width and height values in pixels (in that order).
     161 *                                Default 'medium'.
     162 * @param bool         $constrain Optional. Whether to constrain the image to content width or not.
     163 *                                Default true.
    162164 * @return false|array Array containing the image URL, width, height, and boolean for whether
    163165 *                     the image is an intermediate size. False on failure.
    164166 */
    165 function image_downsize( $id, $size = 'medium' ) {
     167function image_downsize( $id, $size = 'medium', $constrain = true ) {
    166168
    167169        if ( !wp_attachment_is_image($id) )
    168170                return false;
    function image_downsize( $id, $size = 'medium' ) { 
    212214                $height = $meta['height'];
    213215        }
    214216
    215         if ( $img_url) {
    216                 // we have the actual image size, but might need to further constrain it if content_width is narrower
    217                 list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
     217        if ( $img_url ) {
     218
     219                if ( $constrain ) {
     220                        // We have the actual image size, but might need to further constrain it if content_width is narrower.
     221                        list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
     222                }
    218223
    219224                return array( $img_url, $width, $height, $is_intermediate );
    220225        }
    function get_intermediate_image_sizes() { 
    749754 * @return false|array Returns an array (url, width, height, is_intermediate), or false, if no image is available.
    750755 */
    751756function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) {
    752         // get a thumbnail or intermediate image if there is one
    753         $image = image_downsize( $attachment_id, $size );
     757        // Get a thumbnail or intermediate image if there is one.
     758        $image = image_downsize( $attachment_id, $size, false );
     759
    754760        if ( ! $image ) {
    755761                $src = false;
    756762