Docs: Improve the DocBlock for get_attached_file().

Includes:
* Using 3-digit format for the `@since` tag.
* Minor wording updates and formatting corrections.

Follow-up to [3203], [4612], [6379], [8203], [24983], [29090], [55199].

See #51780, #56792.
Built from https://develop.svn.wordpress.org/trunk@55202


git-svn-id: http://core.svn.wordpress.org/trunk@54735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-02-03 00:47:19 +00:00
parent a35991eb44
commit 94ede5b18c
2 changed files with 13 additions and 14 deletions

View File

@ -705,35 +705,34 @@ function create_initial_post_types() {
/** /**
* Retrieves attached file path based on attachment ID. * Retrieves attached file path based on attachment ID.
* *
* Will return intermediate size path if $size param is provided. * Will return intermediate size path if the `$size` parameter is provided.
* *
* By default the path will go through the 'get_attached_file' filter, but * By default the path will go through the {@see 'get_attached_file'} filter, but
* passing a true to the $unfiltered argument of get_attached_file() will * passing `true` to the `$unfiltered` argument will return the file path unfiltered.
* return the file path unfiltered.
* *
* The function works by getting the single post meta name, named * The function works by retrieving the `_wp_attached_file` post meta value.
* '_wp_attached_file' and returning it. This is a convenience function to * This is a convenience function to prevent looking up the meta name and provide
* prevent looking up the meta name and provide a mechanism for sending the * a mechanism for sending the attached filename through a filter.
* attached filename through a filter.
* *
* @since 2.0.0 * @since 2.0.0
* @since 6.2 The `$size` parameter was added * @since 6.2.0 The `$size` parameter was added.
* *
* @param int $attachment_id Attachment ID. * @param int $attachment_id Attachment ID.
* @param bool $unfiltered Optional. Whether to apply filters. Default false. * @param bool $unfiltered Optional. Whether to skip the {@see 'get_attached_file'} filter.
* Default false.
* @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array * @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array
* of width and height values in pixels (in that order). Default ''. * of width and height values in pixels (in that order). Default empty string.
*
* @return string|false The file path to where the attached file should be, false otherwise. * @return string|false The file path to where the attached file should be, false otherwise.
*/ */
function get_attached_file( $attachment_id, $unfiltered = false, $size = '' ) { function get_attached_file( $attachment_id, $unfiltered = false, $size = '' ) {
// Check for intermediate sizes first, otherwise fallback to original attachment size // Check for intermediate sizes first, otherwise fall back to the original attachment size.
if ( ! empty( $size ) ) { if ( ! empty( $size ) ) {
$intermediate_image = image_get_intermediate_size( $attachment_id, $size ); $intermediate_image = image_get_intermediate_size( $attachment_id, $size );
if ( ! $intermediate_image || ! isset( $intermediate_image['path'] ) ) { if ( ! $intermediate_image || ! isset( $intermediate_image['path'] ) ) {
return false; return false;
} }
$file = $intermediate_image['path']; $file = $intermediate_image['path'];
} else { } else {
$file = get_post_meta( $attachment_id, '_wp_attached_file', true ); $file = get_post_meta( $attachment_id, '_wp_attached_file', true );

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.2-alpha-55201'; $wp_version = '6.2-alpha-55202';
/** /**
* 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.