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' ) { |
| 1050 | 1050 | function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $width = null ) { |
| 1051 | 1051 | // Try to get the image width from the $width parameter. |
| 1052 | 1052 | if ( is_numeric( $width ) ) { |
| 1053 | | $img_width = (int) $width; |
| | 1053 | $width = absint( $width ); |
| 1054 | 1054 | // Next, see if a width value was passed in the $size parameter. |
| 1055 | 1055 | } elseif ( is_array( $size ) ) { |
| 1056 | | $img_width = $size[0]; |
| | 1056 | $width = absint( $size[0] ); |
| 1057 | 1057 | // Finally, use the $size name to return the width of the image. |
| 1058 | 1058 | } else { |
| 1059 | 1059 | $image = image_get_intermediate_size( $attachment_id, $size ); |
| 1060 | | $img_width = $image ? $image['width'] : false; |
| | 1060 | $width = $image ? absint( $image['width'] ) : false; |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | | // Bail early if $img_width isn't set. |
| 1064 | | if ( ! $img_width ) { |
| | 1063 | // Bail early if $width isn't set. |
| | 1064 | if ( ! $width ) { |
| 1065 | 1065 | return false; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | // 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 ); |
| 1070 | 1070 | |
| 1071 | 1071 | /** |
| 1072 | 1072 | * Filter the output of wp_get_attachment_image_sizes(). |
| … |
… |
function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $width |
| 1077 | 1077 | * @param int $attachment_id Post ID of the original image. |
| 1078 | 1078 | * @param array|string $size Image size. Accepts any valid image size, or an array of width and height |
| 1079 | 1079 | * 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. |
| 1081 | 1082 | */ |
| 1082 | 1083 | return apply_filters( 'wp_get_attachment_image_sizes', $sizes, $attachment_id, $size, $width ); |
| 1083 | 1084 | } |