From e856a9132102fb69173094bb25fa54dd0a4fd06a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 20 Oct 2020 15:31:06 +0000 Subject: [PATCH] Media: Introduce a filter for `wp_get_attachment_image()` HTML output. Props prionkor, antpb, donmhico, audrasjb, Mista-Flo, hellofromTonya. Fixes #50801. Built from https://develop.svn.wordpress.org/trunk@49234 git-svn-id: http://core.svn.wordpress.org/trunk@48996 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 17 +++++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 726ff6d38e..2403df6a24 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -992,7 +992,7 @@ function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon } /** - * Get an HTML img element representing an image attachment + * Get an HTML img element representing an image attachment. * * While `$size` will accept an array, it is better to register a size with * add_image_size() so that a cropped version is generated. It's much more @@ -1099,7 +1099,20 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f $html .= ' />'; } - return $html; + /** + * HTML img element representing an image attachment. + * + * @since 5.6.0 + * + * @param string $html HTML img element or empty string on failure. + * @param int $attachment_id Image attachment ID. + * @param string|int[] $size Requested image size. Can be any registered image size name, or + * an array of width and height values in pixels (in that order). + * @param bool $icon Whether the image should be treated as an icon. + * @param array $attr Array of attribute values for the image markup, keyed by attribute name. + * See wp_get_attachment_image(). + */ + return apply_filters( 'wp_get_attachment_image', $html, $attachment_id, $size, $icon, $attr ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 1256c9c33e..79b19a670f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49233'; +$wp_version = '5.6-alpha-49234'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.