From b8bfcb0d647056e8302deb702c4aad541b919ae5 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 21 Aug 2016 06:15:30 +0000 Subject: [PATCH] Media: use `wp_get_attachment_metadata()` instead of `get_post_meta()` where appropriate. Adds unit test. Props JorritSchippers. Fixes #36246. Built from https://develop.svn.wordpress.org/trunk@38296 git-svn-id: http://core.svn.wordpress.org/trunk@38237 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 10 +++++----- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 4eb2886205..9fac913386 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -861,7 +861,7 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa // Generate 'srcset' and 'sizes' if not already present. if ( empty( $attr['srcset'] ) ) { - $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); + $image_meta = wp_get_attachment_metadata( $attachment_id ); if ( is_array( $image_meta ) ) { $size_array = array( absint( $width ), absint( $height ) ); @@ -990,7 +990,7 @@ function wp_get_attachment_image_srcset( $attachment_id, $size = 'medium', $imag } if ( ! is_array( $image_meta ) ) { - $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); + $image_meta = wp_get_attachment_metadata( $attachment_id ); } $image_src = $image[0]; @@ -1206,7 +1206,7 @@ function wp_get_attachment_image_sizes( $attachment_id, $size = 'medium', $image } if ( ! is_array( $image_meta ) ) { - $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); + $image_meta = wp_get_attachment_metadata( $attachment_id ); } $image_src = $image[0]; @@ -1239,7 +1239,7 @@ function wp_calculate_image_sizes( $size, $image_src = null, $image_meta = null, $width = absint( $size[0] ); } elseif ( is_string( $size ) ) { if ( ! $image_meta && $attachment_id ) { - $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); + $image_meta = wp_get_attachment_metadata( $attachment_id ); } if ( is_array( $image_meta ) ) { @@ -1314,7 +1314,7 @@ function wp_make_content_images_responsive( $content ) { } foreach ( $selected_images as $image => $attachment_id ) { - $image_meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true ); + $image_meta = wp_get_attachment_metadata( $attachment_id ); $content = str_replace( $image, wp_image_add_srcset_and_sizes( $image, $image_meta, $attachment_id ), $content ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index d18d1839bb..530fc52889 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38295'; +$wp_version = '4.7-alpha-38296'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.