Make WordPress Core

Ticket #34458: 34458.diff

File 34458.diff, 2.0 KB (added by jaspermdegroot, 11 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 30df322..07bac48 100644
    function wp_get_attachment_image_srcset( $attachment_id, $size = 'medium' ) { 
    10501050function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $width = null ) {
    10511051        // Try to get the image width from the $width parameter.
    10521052        if ( is_numeric( $width ) ) {
    1053                 $img_width = (int) $width;
     1053                $width = absint( $width );
    10541054        // Next, see if a width value was passed in the $size parameter.
    10551055        } elseif ( is_array( $size ) ) {
    1056                 $img_width = $size[0];
     1056                $width = absint( $size[0] );
    10571057        // Finally, use the $size name to return the width of the image.
    10581058        } else {
    10591059                $image = image_get_intermediate_size( $attachment_id, $size );
    1060                 $img_width = $image ? $image['width'] : false;
     1060                $width = $image ? absint( $image['width'] ) : false;
    10611061        }
    10621062
    1063         // Bail early if $img_width isn't set.
    1064         if ( ! $img_width ) {
     1063        // Bail early if $width isn't set.
     1064        if ( ! $width ) {
    10651065                return false;
    10661066        }
    10671067
    10681068        // Setup the default sizes attribute.
    1069         $sizes = sprintf( '(max-width: %1$dpx) 100vw, %1$dpx', $img_width );
     1069        $sizes = sprintf( '(max-width: %1$dpx) 100vw, %1$dpx', $width );
    10701070
    10711071        /**
    10721072         * Filter the output of wp_get_attachment_image_sizes().
    function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $width 
    10771077         * @param int          $attachment_id Post ID of the original image.
    10781078         * @param array|string $size          Image size. Accepts any valid image size, or an array of width and height
    10791079         *                                    values in pixels (in that order). Default 'medium'.
    1080          * @param int          $width         Display width of the image.
     1080         * @param int          $width         Display width of the image. Value of the `$width` parameter or the width
     1081         *                                    value from the image size.
    10811082         */
    10821083        return apply_filters( 'wp_get_attachment_image_sizes', $sizes, $attachment_id, $size, $width );
    10831084}