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 |
|---|---|
| 590 | $id = wp_insert_attachment($object, $file); |
| 591 | |
| 592 | list($width, $height, $type, $attr) = getimagesize( $file ); |
| 593 | |
| 594 | if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { |
| 595 | // Add the meta-data |
| 596 | wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
| 597 | |
| 598 | set_theme_mod('header_image', esc_url($url)); |
| 599 | do_action('wp_create_file_in_uploads', $file, $id); // For replication |
| 600 | return $this->finished(); |
| 601 | } elseif ( $width > HEADER_IMAGE_WIDTH ) { |
| 602 | $oitar = $width / HEADER_IMAGE_WIDTH; |
| 603 | $image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
| 604 | if ( is_wp_error( $image ) ) |
| 605 | wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
| 606 | |
| 607 | $image = apply_filters('wp_create_file_in_uploads', $image, $id); // For replication |
| 608 | |
| 609 | $url = str_replace(basename($url), basename($image), $url); |
| 610 | $width = $width / $oitar; |
| 611 | $height = $height / $oitar; |
| 612 | } else { |
| 613 | $oitar = 1; |
| 614 | } |
| 615 | ?> |
| 616 | |
| Line | Code |
| 655 | $_POST['height'] = $_POST['height'] * $_POST['oitar']; |
| 656 | } |
| 657 | |
| 658 | $original = get_attached_file( $_POST['attachment_id'] ); |
| 659 | |
| 660 | $cropped = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); |
| 661 | if ( is_wp_error( $cropped ) ) |
| 662 | wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
| 663 | |
| 664 | $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $_POST['attachment_id']); // For replication |
| 665 | |
| 666 | $parent = get_post($_POST['attachment_id']); |
| 667 | $parent_url = $parent->guid; |
| 668 | $url = str_replace(basename($parent_url), basename($cropped), $parent_url); |
| 669 | |
| 670 | // Construct the object array |
| 671 | $object = array( |
| 672 | 'ID' => $_POST['attachment_id'], |
| 673 | 'post_title' => basename($cropped), |