Make WordPress Core

Changeset 27357


Ignore:
Timestamp:
03/02/2014 08:55:10 PM (11 years ago)
Author:
DrewAPicture
Message:

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

Props theorboman. Props kpdesign for the cleanup.
Fixes #26149.

File:
1 edited

Legend:

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

    r26648 r27357  
    204204function wp_stream_image( $image, $mime_type, $post_id ) {
    205205    if ( $image instanceof WP_Image_Editor ) {
    206         $image = apply_filters('image_editor_save_pre', $image, $post_id);
     206
     207        /**
     208         * Filter the WP_Image_Editor instance for the image to be streamed to the browser.
     209         *
     210         * @since 3.5.0
     211         *
     212         * @param WP_Image_Editor $image   WP_Image_Editor instance.
     213         * @param int             $post_id Post ID.
     214         */
     215        $image = apply_filters( 'image_editor_save_pre', $image, $post_id );
    207216
    208217        if ( is_wp_error( $image->stream( $mime_type ) ) )
     
    213222        _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
    214223
    215         $image = apply_filters('image_save_pre', $image, $post_id);
     224        /**
     225         * Filter the GD image resource to be streamed to the browser.
     226         *
     227         * @since 2.9.0
     228         * @deprecated 3.5.0 Use image_editor_save_pre instead.
     229         *
     230         * @param resource $image   Image resource to be streamed.
     231         * @param int      $post_id Post ID.
     232         */
     233        $image = apply_filters( 'image_save_pre', $image, $post_id );
    216234
    217235        switch ( $mime_type ) {
     
    242260function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
    243261    if ( $image instanceof WP_Image_Editor ) {
    244         $image = apply_filters('image_editor_save_pre', $image, $post_id);
    245         $saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id);
     262
     263        /** This filter is documented in wp-admin/includes/image-edit.php */
     264        $image = apply_filters( 'image_editor_save_pre', $image, $post_id );
     265
     266        /**
     267         * Filter whether to skip saving the image file.
     268         *
     269         * Returning a non-null value will short-circuit the save method,
     270         * returning that value instead.
     271         *
     272         * @since 3.5.0
     273         *
     274         * @param mixed           $override  Value to return instead of saving. Default null.
     275         * @param string          $filename  Name of the file to be saved.
     276         * @param WP_Image_Editor $image     WP_Image_Editor instance.
     277         * @param string          $mime_type Image mime type.
     278         * @param int             $post_id   Post ID.
     279         */
     280        $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id );
    246281
    247282        if ( null !== $saved )
     
    252287        _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
    253288
    254         $image = apply_filters('image_save_pre', $image, $post_id);
    255         $saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id);
     289        /** This filter is documented in wp-admin/includes/image-edit.php */
     290        $image = apply_filters( 'image_save_pre', $image, $post_id );
     291
     292        /**
     293         * Filter whether to skip saving the image file.
     294         *
     295         * Returning a non-null value will short-circuit the save method,
     296         * returning that value instead.
     297         *
     298         * @since 2.9.0
     299         * @deprecated 3.5.0 Use wp_save_image_editor_file instead.
     300         *
     301         * @param mixed           $override  Value to return instead of saving. Default null.
     302         * @param string          $filename  Name of the file to be saved.
     303         * @param WP_Image_Editor $image     WP_Image_Editor instance.
     304         * @param string          $mime_type Image mime type.
     305         * @param int             $post_id   Post ID.
     306         */
     307        $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id );
    256308
    257309        if ( null !== $saved )
     
    260312        switch ( $mime_type ) {
    261313            case 'image/jpeg':
     314
    262315                /** This filter is documented in wp-includes/class-wp-image-editor.php */
    263316                return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
     
    399452
    400453    // image resource before applying the changes
    401     if ( $image instanceof WP_Image_Editor )
    402         $image = apply_filters('wp_image_editor_before_change', $image, $changes);
    403     elseif ( is_resource( $image ) )
    404         $image = apply_filters('image_edit_before_change', $image, $changes);
     454    if ( $image instanceof WP_Image_Editor ) {
     455
     456        /**
     457         * Filter the WP_Image_Editor instance before applying changes to the image.
     458         *
     459         * @since 3.5.0
     460         *
     461         * @param WP_Image_Editor $image   WP_Image_Editor instance.
     462         * @param array           $changes Array of change operations.
     463         */
     464        $image = apply_filters( 'wp_image_editor_before_change', $image, $changes );
     465    } elseif ( is_resource( $image ) ) {
     466
     467        /**
     468         * Filter the GD image resource before applying changes to the image.
     469         *
     470         * @since 2.9.0
     471         * @deprecated 3.5.0 Use wp_image_editor_before_change instead.
     472         *
     473         * @param resource $image   GD image resource.
     474         * @param array    $changes Array of change operations.
     475         */
     476        $image = apply_filters( 'image_edit_before_change', $image, $changes );
     477    }
    405478
    406479    foreach ( $changes as $operation ) {
     
    452525function stream_preview_image( $post_id ) {
    453526    $post = get_post( $post_id );
     527
     528    /** This filter is documented in wp-admin/admin.php */
    454529    @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
    455530
     
    501576                // delete only if it's edited image
    502577                if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
     578
    503579                    /** This filter is documented in wp-admin/custom-header.php */
    504                     $delpath = apply_filters('wp_delete_file', $file);
     580                    $delpath = apply_filters( 'wp_delete_file', $file );
    505581                    @unlink($delpath);
    506582                }
     
    726802
    727803    if ( $delete ) {
     804
    728805        /** This filter is documented in wp-admin/custom-header.php */
    729         $delpath = apply_filters('wp_delete_file', $new_path);
     806        $delpath = apply_filters( 'wp_delete_file', $new_path );
    730807        @unlink( $delpath );
    731808    }
Note: See TracChangeset for help on using the changeset viewer.