Make WordPress Core

Changeset 55202


Ignore:
Timestamp:
02/03/2023 12:45:24 AM (20 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r55199 r55202  
    706706 * Retrieves attached file path based on attachment ID.
    707707 *
    708  * Will return intermediate size path if $size param is provided.
    709  *
    710  * By default the path will go through the 'get_attached_file' filter, but
    711  * passing a true to the $unfiltered argument of get_attached_file() will
    712  * return the file path unfiltered.
    713  *
    714  * The function works by getting the single post meta name, named
    715  * '_wp_attached_file' and returning it. This is a convenience function to
    716  * prevent looking up the meta name and provide a mechanism for sending the
    717  * attached filename through a filter.
     708 * Will return intermediate size path if the `$size` parameter is provided.
     709 *
     710 * By default the path will go through the {@see 'get_attached_file'} filter, but
     711 * passing `true` to the `$unfiltered` argument will return the file path unfiltered.
     712 *
     713 * The function works by retrieving the `_wp_attached_file` post meta value.
     714 * This is a convenience function to prevent looking up the meta name and provide
     715 * a mechanism for sending the attached filename through a filter.
    718716 *
    719717 * @since 2.0.0
    720  * @since 6.2 The `$size` parameter was added
     718 * @since 6.2.0 The `$size` parameter was added.
    721719 *
    722720 * @param int          $attachment_id Attachment ID.
    723  * @param bool         $unfiltered    Optional. Whether to apply filters. Default false.
     721 * @param bool         $unfiltered    Optional. Whether to skip the {@see 'get_attached_file'} filter.
     722 *                                    Default false.
    724723 * @param string|int[] $size          Optional. Image size. Accepts any registered image size name, or an array
    725  *                                    of width and height values in pixels (in that order). Default ''.
    726  *
     724 *                                    of width and height values in pixels (in that order). Default empty string.
    727725 * @return string|false The file path to where the attached file should be, false otherwise.
    728726 */
    729727function get_attached_file( $attachment_id, $unfiltered = false, $size = '' ) {
    730728
    731     // Check for intermediate sizes first, otherwise fallback to original attachment size
     729    // Check for intermediate sizes first, otherwise fall back to the original attachment size.
    732730    if ( ! empty( $size ) ) {
    733731        $intermediate_image = image_get_intermediate_size( $attachment_id, $size );
     
    735733            return false;
    736734        }
     735
    737736        $file = $intermediate_image['path'];
    738737    } else {
Note: See TracChangeset for help on using the changeset viewer.