Make WordPress Core

Ticket #25832: 25832.3.diff

File 25832.3.diff, 4.4 KB (added by kpdesign, 11 years ago)

Final pass

  • src/wp-admin/includes/image.php

     
    102102                                $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
    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 array of image sizes.
     111                 */
    105112                $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
    106113
    107114                if ( $sizes ) {
     
    155162        if ( isset( $metadata['image']['data'] ) )
    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}
    160175
     
    268283                 }
    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 );
    274295
     
    316337                        $meta[ $key ] = utf8_encode( $meta[ $key ] );
    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
    321351}
     
    351381        else
    352382                $result = true;
    353383
    354         return apply_filters('file_is_displayable_image', $result, $path);
     384        /**
     385         * Filter whether the current image is displayable in the browser.
     386         *
     387         * @since 2.5.0
     388         *
     389         * @param bool   $result Whether the image can be displayed. Default false.
     390         * @param string $path   Path to the image.
     391         */
     392        return apply_filters( 'file_is_displayable_image', $result, $path );
    355393}
    356394
    357395/**
     
    384422                        break;
    385423        }
    386424        if ( is_resource($image) ) {
    387                 $image = apply_filters('load_image_to_edit', $image, $attachment_id, $size);
     425                /**
     426                 * Filter the current image being loaded for editing.
     427                 *
     428                 * @since 2.9.0
     429                 *
     430                 * @param resource $image         Current image.
     431                 * @param string   $attachment_id Attachment ID.
     432                 * @param string   $size          Size of the image.
     433                 */
     434                $image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size );
    388435                if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
    389436                        imagealphablending($image, false);
    390437                        imagesavealpha($image, true);
     
    411458
    412459        if ( $filepath && file_exists( $filepath ) ) {
    413460                if ( 'full' != $size && ( $data = image_get_intermediate_size( $attachment_id, $size ) ) ) {
     461                        /**
     462                         * Filter the path to the current image.
     463                         *
     464                         * @since 3.1.0
     465                         *
     466                         * @param string $path          Path to the current image.
     467                         * @param string $attachment_id Attachment ID.
     468                         * @param string $size          Size of the image.
     469                         */
    414470                        $filepath = apply_filters( 'load_image_to_edit_filesystempath', path_join( dirname( $filepath ), $data['file'] ), $attachment_id, $size );
    415471                }
    416472        } elseif ( function_exists( 'fopen' ) && function_exists( 'ini_get' ) && true == ini_get( 'allow_url_fopen' ) ) {
     473                /**
     474                 * Filter the image URL if not in the local filesystem.
     475                 *
     476                 * @since 3.1.0
     477                 *
     478                 * @param string $image_url     Current image URL.
     479                 * @param string $attachment_id Attachment ID.
     480                 * @param string $size          Size of the image.
     481                 */
    417482                $filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size );
    418483        }
    419484
     485        /**
     486         * Filter the returned path or URL of the current image.
     487         *
     488         * @since 2.9.0
     489         *
     490         * @param string|bool $filepath      File path or URL to current image, or false.
     491         * @param string      $attachment_id Attachment ID.
     492         * @param string      $size          Size of the image.
     493         */
    420494        return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size );
    421495}
    422496