From ea3d7c7962743082fcaf05d842075e1caaceb303 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 3 Nov 2015 00:19:28 +0000 Subject: [PATCH] Responsive images: - More fixes to inline docs. - Replace the last `wp_get_attachment_metadata()` with `get_post_meta()`. - For consistency only accept array or named size in `wp_get_attachment_image_sizes()`. Props jaspermdegroot. See #34430. Built from https://develop.svn.wordpress.org/trunk@35491 git-svn-id: http://core.svn.wordpress.org/trunk@35455 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 19 +++++++++++++------ wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 79fb36ee71..91a3e52edd 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -930,7 +930,7 @@ function _wp_get_image_size_from_meta( $size_name, $image_meta ) { * * @since 4.4.0 * - * @param int $attachment_id Optional. Image attachment ID. + * @param int $attachment_id Image attachment ID. * @param array|string $size Image size. Accepts any valid image size, or an array of width and height * values in pixels (in that order). Default 'medium'. * @param array $image_meta Optional. The image meta data as returned by 'wp_get_attachment_metadata()'. @@ -1059,7 +1059,16 @@ function wp_calculate_image_srcset( $image_name, $size_array, $image_meta, $atta * * @since 4.4.0 * - * @param array $sources An array of image URLs and widths. + * @param array $sources An array of sources to include in the 'srcset'. Each source + * consists of an array containing the URL and the descriptor + * type and value (default: the image width): + * + * image width => array( + * 'url' => string, + * 'descriptor' => string ('w' or 'x'), + * 'value' => integer (width or pixel density) + * }, + * * @param int $attachment_id Image attachment ID. * @param array $size_array Array of width and height values in pixels (in that order). * @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'. @@ -1098,13 +1107,11 @@ function wp_calculate_image_srcset( $image_name, $size_array, $image_meta, $atta function wp_get_attachment_image_sizes( $size, $image_meta = null, $attachment_id = 0, $image_url = null ) { $width = 0; - if ( is_numeric( $size ) ) { - $width = absint( $size ); - } elseif ( is_array( $size ) ) { + if ( is_array( $size ) ) { $width = absint( $size[0] ); } elseif ( is_string( $size ) ) { if ( ! $image_meta && $attachment_id ) { - $image_meta = wp_get_attachment_metadata( $attachment_id ); + $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); } if ( is_array( $image_meta ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 5234a4c737..aff61e2ba6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta2-35490'; +$wp_version = '4.4-beta2-35491'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.