Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_create_file_in_uploads

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
3095                     // Delete the temporary cropped file, we don't need it.
3096                     wp_delete_file( $cropped );
3097
3098                     // Additional sizes in wp_prepare_attachment_for_js().
3099                     add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) );
3100                     break;
3101                }
3102
3103                /** This filter is documented in wp-admin/custom-header.php */
3104                $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
3105                $object  = $wp_site_icon->create_attachment_object( $cropped, $attachment_id );
3106                unset( $object['ID'] );
3107
3108                // Update the attachment.
3109                add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
3110                $attachment_id = $wp_site_icon->insert_attachment( $object, $cropped );
3111                remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
3112
3113                // Additional sizes in wp_prepare_attachment_for_js().
 
Line Code
3124                 * @since 4.3.0
3125                 *
3126                 * @param string $context       The Customizer control requesting the cropped image.
3127                 * @param int    $attachment_id The attachment ID of the original image.
3128                 * @param string $cropped       Path to the cropped image file.
3129                 */
3130                do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped );
3131
3132                /** This filter is documented in wp-admin/custom-header.php */
3133                $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
3134
3135                $parent_url = get_post( $attachment_id )->guid;
3136                $url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
3137
3138                $size       = @getimagesize( $cropped );
3139                $image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
3140
3141                $object = array(
3142                     'post_title'     => basename( $cropped ),