WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 4 times in this file.
| Line | Code |
|---|---|
| 887 | * Filters the attachment file path after the custom header or background image is set. |
| 888 | * |
| 889 | * Used for file replication. |
| 890 | * |
| 891 | * @since 2.1.0 |
| 892 | * |
| 893 | * @param string $file Path to the file. |
| 894 | * @param int $attachment_id Attachment ID. |
| 895 | */ |
| 896 | $file = apply_filters( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication. |
| 897 | |
| 898 | return $this->finished(); |
| 899 | } elseif ( $width > $max_width ) { |
| 900 | $oitar = $width / $max_width; |
| 901 | |
| 902 | $image = wp_crop_image( |
| 903 | $attachment_id, |
| 904 | 0, |
| 905 | 0, |
| Line | Code |
| 910 | false, |
| 911 | str_replace( wp_basename( $file ), 'midsize-' . wp_basename( $file ), $file ) |
| 912 | ); |
| 913 | |
| 914 | if ( ! $image || is_wp_error( $image ) ) { |
| 915 | wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
| 916 | } |
| 917 | |
| 918 | /** This filter is documented in wp-admin/includes/class-custom-image-header.php */ |
| 919 | $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication. |
| 920 | |
| 921 | $url = str_replace( wp_basename( $url ), wp_basename( $image ), $url ); |
| 922 | $width = $width / $oitar; |
| 923 | $height = $height / $oitar; |
| 924 | } else { |
| 925 | $oitar = 1; |
| 926 | } |
| 927 | ?> |
| 928 | |
| Line | Code |
| 1069 | } else { |
| 1070 | $cropped = get_attached_file( $attachment_id ); |
| 1071 | } |
| 1072 | |
| 1073 | if ( ! $cropped || is_wp_error( $cropped ) ) { |
| 1074 | wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
| 1075 | } |
| 1076 | |
| 1077 | /** This filter is documented in wp-admin/includes/class-custom-image-header.php */ |
| 1078 | $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. |
| 1079 | |
| 1080 | $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'custom-header' ); |
| 1081 | |
| 1082 | if ( ! empty( $_POST['create-new-attachment'] ) ) { |
| 1083 | unset( $attachment['ID'] ); |
| 1084 | } |
| 1085 | |
| 1086 | // Update the attachment. |
| 1087 | $attachment_id = $this->insert_attachment( $attachment, $cropped ); |
| Line | Code |
| 1415 | (int) $dimensions['dst_width'], |
| 1416 | (int) $dimensions['dst_height'] |
| 1417 | ); |
| 1418 | |
| 1419 | if ( ! $cropped || is_wp_error( $cropped ) ) { |
| 1420 | wp_send_json_error( array( 'message' => __( 'Image could not be processed. Please go back and try again.' ) ) ); |
| 1421 | } |
| 1422 | |
| 1423 | /** This filter is documented in wp-admin/includes/class-custom-image-header.php */ |
| 1424 | $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. |
| 1425 | |
| 1426 | $attachment = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'custom-header' ); |
| 1427 | |
| 1428 | $previous = $this->get_previous_crop( $attachment ); |
| 1429 | |
| 1430 | if ( $previous ) { |
| 1431 | $attachment['ID'] = $previous; |
| 1432 | } else { |
| 1433 | unset( $attachment['ID'] ); |