Make WordPress Core

Changeset 27202


Ignore:
Timestamp:
02/20/2014 06:26:51 AM (13 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-admin/includes/image.php.

Props theorboman, kpdesign.
Fixes #25832.

File:
1 edited

Legend:

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

    r25968 r27202  
    103103                }
    104104
     105                /**
     106                 * Filter the image sizes automatically generated when uploading an image.
     107                 *
     108                 * @since 2.9.0
     109                 *
     110                 * @param array $sizes An associative array of image sizes.
     111                 */
    105112                $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
    106113
     
    156163                unset( $metadata['image']['data'] );
    157164
     165        /**
     166         * Filter the generated attachment meta data.
     167         *
     168         * @since 2.1.0
     169         *
     170         * @param array $metadata      An array of attachment meta data.
     171         * @param int   $attachment_id Current attachment ID.
     172         */
    158173        return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
    159174}
     
    269284        }
    270285
    271         // fetch additional info from exif if available
     286        /**
     287         * Filter the image types to check for exif data.
     288         *
     289         * @since 2.5.0
     290         *
     291         * @param array $image_types Image types to check for exif data.
     292         */
    272293        if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) {
    273294                $exif = @exif_read_data( $file );
     
    317338        }
    318339
     340        /**
     341         * Filter the array of meta data read from an image's exif data.
     342         *
     343         * @since 2.5.0
     344         *
     345         * @param array  $meta            Image meta data.
     346         * @param string $file            Path to image file.
     347         * @param int    $sourceImageType Type of image.
     348         */
    319349        return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
    320350
     
    338368 *
    339369 * @since 2.5.0
    340  * @uses apply_filters() Calls 'file_is_displayable_image' on $result and $path.
    341370 *
    342371 * @param string $path File path to test.
     
    352381                $result = true;
    353382
    354         return apply_filters('file_is_displayable_image', $result, $path);
     383        /**
     384         * Filter whether the current image is displayable in the browser.
     385         *
     386         * @since 2.5.0
     387         *
     388         * @param bool   $result Whether the image can be displayed. Default true.
     389         * @param string $path   Path to the image.
     390         */
     391        return apply_filters( 'file_is_displayable_image', $result, $path );
    355392}
    356393
     
    385422        }
    386423        if ( is_resource($image) ) {
    387                 $image = apply_filters('load_image_to_edit', $image, $attachment_id, $size);
     424                /**
     425                 * Filter the current image being loaded for editing.
     426                 *
     427                 * @since 2.9.0
     428                 *
     429                 * @param resource $image         Current image.
     430                 * @param string   $attachment_id Attachment ID.
     431                 * @param string   $size          Image size.
     432                 */
     433                $image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size );
    388434                if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
    389435                        imagealphablending($image, false);
     
    412458        if ( $filepath && file_exists( $filepath ) ) {
    413459                if ( 'full' != $size && ( $data = image_get_intermediate_size( $attachment_id, $size ) ) ) {
     460                        /**
     461                         * Filter the path to the current image.
     462                         *
     463                         * The filter is evaluated for all image sizes except 'full'.
     464                         *
     465                         * @since 3.1.0
     466                         *
     467                         * @param string $path          Path to the current image.
     468                         * @param string $attachment_id Attachment ID.
     469                         * @param string $size          Size of the image.
     470                         */
    414471                        $filepath = apply_filters( 'load_image_to_edit_filesystempath', path_join( dirname( $filepath ), $data['file'] ), $attachment_id, $size );
    415472                }
    416473        } elseif ( function_exists( 'fopen' ) && function_exists( 'ini_get' ) && true == ini_get( 'allow_url_fopen' ) ) {
     474                /**
     475                 * Filter the image URL if not in the local filesystem.
     476                 *
     477                 * The filter is only evaluated if fopen is enabled on the server.
     478                 *
     479                 * @since 3.1.0
     480                 *
     481                 * @param string $image_url     Current image URL.
     482                 * @param string $attachment_id Attachment ID.
     483                 * @param string $size          Size of the image.
     484                 */
    417485                $filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size );
    418486        }
    419487
     488        /**
     489         * Filter the returned path or URL of the current image.
     490         *
     491         * @since 2.9.0
     492         *
     493         * @param string|bool $filepath      File path or URL to current image, or false.
     494         * @param string      $attachment_id Attachment ID.
     495         * @param string      $size          Size of the image.
     496         */
    420497        return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size );
    421498}
Note: See TracChangeset for help on using the changeset viewer.