WordPress.org

Make WordPress Core

Changeset 41288


Ignore:
Timestamp:
08/22/2017 11:11:23 AM (2 years ago)
Author:
johnbillion
Message:

Media: Rename several attachment related parameters from $post_id to $attachment_id for clarity, and improve related
documentation.

See #41017

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image-edit.php

    r40922 r41288  
    232232/**
    233233 * Streams image in WP_Image_Editor to browser.
    234  * Provided for backcompat reasons
    235  *
    236  * @param WP_Image_Editor $image
    237  * @param string $mime_type
    238  * @param int $post_id
    239  * @return bool
    240  */
    241 function wp_stream_image( $image, $mime_type, $post_id ) {
     234 *
     235 * @param WP_Image_Editor $image         The image editor instance.
     236 * @param string          $mime_type     The mime type of the image.
     237 * @param int             $attachment_id The image's attachment post ID.
     238 * @return bool True on success, false on failure.
     239 */
     240function wp_stream_image( $image, $mime_type, $attachment_id ) {
    242241    if ( $image instanceof WP_Image_Editor ) {
    243242
     
    247246         * @since 3.5.0
    248247         *
    249          * @param WP_Image_Editor $image   WP_Image_Editor instance.
    250          * @param int             $post_id Post ID.
     248         * @param WP_Image_Editor $image         The image editor instance.
     249         * @param int             $attachment_id The attachment post ID.
    251250         */
    252         $image = apply_filters( 'image_editor_save_pre', $image, $post_id );
     251        $image = apply_filters( 'image_editor_save_pre', $image, $attachment_id );
    253252
    254253        if ( is_wp_error( $image->stream( $mime_type ) ) )
     
    265264         * @deprecated 3.5.0 Use image_editor_save_pre instead.
    266265         *
    267          * @param resource $image   Image resource to be streamed.
    268          * @param int      $post_id Post ID.
     266         * @param resource $image         Image resource to be streamed.
     267         * @param int      $attachment_id The attachment post ID.
    269268         */
    270         $image = apply_filters( 'image_save_pre', $image, $post_id );
     269        $image = apply_filters( 'image_save_pre', $image, $attachment_id );
    271270
    272271        switch ( $mime_type ) {
  • trunk/src/wp-includes/class-wp-image-editor-gd.php

    r41162 r41288  
    430430     * @since 3.5.0
    431431     *
    432      * @param string $mime_type
    433      * @return bool
     432     * @param string $mime_type The mime type of the image.
     433     * @return bool True on success, false on failure.
    434434     */
    435435    public function stream( $mime_type = null ) {
  • trunk/src/wp-includes/class-wp-image-editor-imagick.php

    r41162 r41288  
    653653     * @since 3.5.0
    654654     *
    655      * @param string $mime_type
    656      * @return true|WP_Error
     655     * @param string $mime_type The mime type of the image.
     656     * @return bool|WP_Error True on success, WP_Error object on failure.
    657657     */
    658658    public function stream( $mime_type = null ) {
  • trunk/src/wp-includes/class-wp-image-editor.php

    r41162 r41288  
    165165     * @abstract
    166166     *
    167      * @param string $mime_type
    168      * @return bool|WP_Error
     167     * @param string $mime_type The mime type of the image.
     168     * @return bool|WP_Error True on success, WP_Error object or false on failure.
    169169     */
    170170    abstract public function stream( $mime_type = null );
  • trunk/src/wp-includes/post.php

    r41034 r41288  
    49644964 * @since 2.1.0
    49654965 *
    4966  * @param int  $post_id    Attachment ID. Default 0.
    4967  * @param bool $unfiltered Optional. If true, filters are not run. Default false.
     4966 * @param int  $attachment_id Attachment post ID. Defaults to global $post.
     4967 * @param bool $unfiltered    Optional. If true, filters are not run. Default false.
    49684968 * @return mixed Attachment meta field. False on failure.
    49694969 */
    4970 function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
    4971     $post_id = (int) $post_id;
    4972     if ( !$post = get_post( $post_id ) )
     4970function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
     4971    $attachment_id = (int) $attachment_id;
     4972    if ( ! $post = get_post( $attachment_id ) ) {
    49734973        return false;
     4974    }
    49744975
    49754976    $data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
     
    49834984     * @since 2.1.0
    49844985     *
    4985      * @param array|bool $data    Array of meta data for the given attachment, or false
    4986      *                            if the object does not exist.
    4987      * @param int        $post_id Attachment ID.
     4986     * @param array|bool $data          Array of meta data for the given attachment, or false
     4987     *                                  if the object does not exist.
     4988     * @param int        $attachment_id Attachment post ID.
    49884989     */
    49894990    return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
     
    49954996 * @since 2.1.0
    49964997 *
    4997  * @param int   $post_id Attachment ID.
    4998  * @param array $data    Attachment data.
     4998 * @param int   $attachment_id Attachment post ID.
     4999 * @param array $data          Attachment meta data.
    49995000 * @return int|bool False if $post is invalid.
    50005001 */
    5001 function wp_update_attachment_metadata( $post_id, $data ) {
    5002     $post_id = (int) $post_id;
    5003     if ( !$post = get_post( $post_id ) )
     5002function wp_update_attachment_metadata( $attachment_id, $data ) {
     5003    $attachment_id = (int) $attachment_id;
     5004    if ( ! $post = get_post( $attachment_id ) ) {
    50045005        return false;
     5006    }
    50055007
    50065008    /**
     
    50095011     * @since 2.1.0
    50105012     *
    5011      * @param array $data    Array of updated attachment meta data.
    5012      * @param int   $post_id Attachment ID.
     5013     * @param array $data          Array of updated attachment meta data.
     5014     * @param int   $attachment_id Attachment post ID.
    50135015     */
    50145016    if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
     
    50255027 * @global string $pagenow
    50265028 *
    5027  * @param int $post_id Optional. Attachment ID. Default 0.
     5029 * @param int $attachment_id Optional. Attachment post ID. Defaults to global $post.
    50285030 * @return string|false Attachment URL, otherwise false.
    50295031 */
    5030 function wp_get_attachment_url( $post_id = 0 ) {
    5031     $post_id = (int) $post_id;
    5032     if ( !$post = get_post( $post_id ) )
     5032function wp_get_attachment_url( $attachment_id = 0 ) {
     5033    $attachment_id = (int) $attachment_id;
     5034    if ( ! $post = get_post( $attachment_id ) ) {
    50335035        return false;
     5036    }
    50345037
    50355038    if ( 'attachment' != $post->post_type )
     
    50735076     * @since 2.1.0
    50745077     *
    5075      * @param string $url     URL for the given attachment.
    5076      * @param int    $post_id Attachment ID.
     5078     * @param string $url           URL for the given attachment.
     5079     * @param int    $attachment_id Attachment post ID.
    50775080     */
    50785081    $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
Note: See TracChangeset for help on using the changeset viewer.