Skip to content

Commit de5d82f

Browse files
Docs: Improve documentation for the $attr parameter of wp_get_attachment_image().
Props juanfra, Mte90, DrewAPicture, joemcgill, SergeyBiryukov. Fixes #36661. git-svn-id: https://develop.svn.wordpress.org/trunk@47249 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0c07311 commit de5d82f

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

src/wp-includes/media.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
363363
* @since 2.5.0
364364
*
365365
* @param int $id Attachment ID.
366-
* @param string $alt Image Description for the alt attribute.
367-
* @param string $title Image Description for the title attribute.
366+
* @param string $alt Image description for the alt attribute.
367+
* @param string $title Image description for the title attribute.
368368
* @param string $align Part of the class name for aligning the image.
369369
* @param string|array $size Optional. Registered image size to retrieve a tag for. Accepts any
370370
* valid image size, or an array of width and height values in pixels
@@ -402,8 +402,8 @@ function get_image_tag( $id, $alt, $title, $align, $size = 'medium' ) {
402402
*
403403
* @param string $html HTML content for the image.
404404
* @param int $id Attachment ID.
405-
* @param string $alt Alternate text.
406-
* @param string $title Attachment title.
405+
* @param string $alt Image description for the alt attribute.
406+
* @param string $title Image description for the title attribute.
407407
* @param string $align Part of the class name for aligning the image.
408408
* @param string|array $size Size of image. Image size or array of width and height values (in that order).
409409
* Default 'medium'.
@@ -999,16 +999,26 @@ function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon
999999
* @param string|array $size Optional. Image size. Accepts any valid image size, or an array of width
10001000
* and height values in pixels (in that order). Default 'thumbnail'.
10011001
* @param bool $icon Optional. Whether the image should be treated as an icon. Default false.
1002-
* @param string|array $attr Optional. Attributes for the image markup. Default empty.
1002+
* @param string|array $attr {
1003+
* Optional. Attributes for the image markup.
1004+
*
1005+
* @type string $src Image attachment URL.
1006+
* @type string $class CSS class name or space-separated list of classes.
1007+
* Default `attachment-$size_class size-$size_class`,
1008+
* where `$size_class` is the image size being requested.
1009+
* @type string $alt Image description for the alt attribute.
1010+
* @type string $srcset The 'srcset' attribute value.
1011+
* @type string $sizes The 'sizes' attribute value.
1012+
* }
10031013
* @return string HTML img element or empty string on failure.
10041014
*/
10051015
function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = false, $attr = '' ) {
10061016
$html = '';
10071017
$image = wp_get_attachment_image_src( $attachment_id, $size, $icon );
10081018
if ( $image ) {
1009-
list($src, $width, $height) = $image;
1010-
$hwstring = image_hwstring( $width, $height );
1011-
$size_class = $size;
1019+
list( $src, $width, $height ) = $image;
1020+
$hwstring = image_hwstring( $width, $height );
1021+
$size_class = $size;
10121022
if ( is_array( $size_class ) ) {
10131023
$size_class = join( 'x', $size_class );
10141024
}
@@ -1046,6 +1056,7 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f
10461056
* @since 2.8.0
10471057
*
10481058
* @param string[] $attr Array of attribute values for the image markup, keyed by attribute name.
1059+
* See wp_get_attachment_image().
10491060
* @param WP_Post $attachment Image attachment post.
10501061
* @param string|array $size Requested size. Image size or array of width and height values
10511062
* (in that order). Default 'thumbnail'.

0 commit comments

Comments
 (0)