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 3 times in this file.
| Line | Code |
|---|---|
| 654 | |
| 655 | list($width, $height, $type, $attr) = getimagesize( $file ); |
| 656 | |
| 657 | if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { |
| 658 | // Add the meta-data |
| 659 | wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
| 660 | update_post_meta( $id, '_wp_attachment_is_custom_header', get_option('stylesheet' ) ); |
| 661 | |
| 662 | set_theme_mod('header_image', esc_url($url)); |
| 663 | do_action('wp_create_file_in_uploads', $file, $id); // For replication |
| 664 | return $this->finished(); |
| 665 | } elseif ( $width > HEADER_IMAGE_WIDTH ) { |
| 666 | $oitar = $width / HEADER_IMAGE_WIDTH; |
| 667 | $image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
| 668 | if ( is_wp_error( $image ) ) |
| 669 | wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
| 670 | |
| 671 | $image = apply_filters('wp_create_file_in_uploads', $image, $id); // For replication |
| 672 | |
| 673 | $url = str_replace(basename($url), basename($image), $url); |
| 674 | $width = $width / $oitar; |
| 675 | $height = $height / $oitar; |
| 676 | } else { |
| 677 | $oitar = 1; |
| 678 | } |
| 679 | ?> |
| 680 | |
| Line | Code |
| 723 | } |
| 724 | |
| 725 | $attachment_id = absint( $_POST['attachment_id'] ); |
| 726 | $original = get_attached_file($attachment_id); |
| 727 | |
| 728 | $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); |
| 729 | if ( is_wp_error( $cropped ) ) |
| 730 | wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
| 731 | |
| 732 | $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication |
| 733 | |
| 734 | $parent = get_post($attachment_id); |
| 735 | $parent_url = $parent->guid; |
| 736 | $url = str_replace(basename($parent_url), basename($cropped), $parent_url); |
| 737 | |
| 738 | // Construct the object array |
| 739 | $object = array( |
| 740 | 'ID' => $attachment_id, |
| 741 | 'post_title' => basename($cropped), |