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
4034                     // Delete the temporary cropped file, we don't need it.
4035                     wp_delete_file( $cropped );
4036
4037                     // Additional sizes in wp_prepare_attachment_for_js().
4038                     add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) );
4039                     break;
4040                }
4041
4042                /** This filter is documented in wp-admin/includes/class-custom-image-header.php */
4043                $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
4044
4045                // Copy attachment properties.
4046                $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, $context );
4047
4048                // Update the attachment.
4049                add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
4050                $attachment_id = $wp_site_icon->insert_attachment( $attachment, $cropped );
4051                remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
4052
 
Line Code
4063                 * @since 4.3.0
4064                 *
4065                 * @param string $context       The Customizer control requesting the cropped image.
4066                 * @param int    $attachment_id The attachment ID of the original image.
4067                 * @param string $cropped       Path to the cropped image file.
4068                 */
4069                do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped );
4070
4071                /** This filter is documented in wp-admin/includes/class-custom-image-header.php */
4072                $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
4073
4074                // Copy attachment properties.
4075                $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, $context );
4076
4077                $attachment_id = wp_insert_attachment( $attachment, $cropped );
4078                $metadata      = wp_generate_attachment_metadata( $attachment_id, $cropped );
4079
4080                /**
4081                 * Filters the cropped image attachment metadata.