Media: Add a new function, `wp_get_attachment_image_url()`, which is a shortcut for `wp_get_attachment_image_src()` - same function signature, but returns just the URL based on `$size`.
Adds unit test. Props dipesh.kakadiya, swissspidy, sebastian.pisula. Fixes #33878. Built from https://develop.svn.wordpress.org/trunk@34372 git-svn-id: http://core.svn.wordpress.org/trunk@34336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
39552b63ca
commit
2ddc1d2f3a
|
@ -793,6 +793,22 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL of an image attachment.
|
||||||
|
*
|
||||||
|
* @since 4.4.0
|
||||||
|
*
|
||||||
|
* @param int $attachment_id Image attachment ID.
|
||||||
|
* @param string|array $size Optional. Registered image size to retrieve the source for or a flat
|
||||||
|
* array of height and width dimensions. Default 'thumbnail'.
|
||||||
|
* @param bool $icon Optional. Whether the image should be treated as an icon. Default false.
|
||||||
|
* @return string|false Attachment URL or false if no image is available.
|
||||||
|
*/
|
||||||
|
function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon = false ) {
|
||||||
|
$image = wp_get_attachment_image_src( $attachment_id, $size, $icon );
|
||||||
|
return isset( $image['0'] ) ? $image['0'] : false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a 'wp-post-image' class to post thumbnails. Internal use only.
|
* Adds a 'wp-post-image' class to post thumbnails. Internal use only.
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34371';
|
$wp_version = '4.4-alpha-34372';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue