Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: attachment_fields_to_save

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

Line Code
649            * Filter the attachment fields to be saved.
650            *
651            * @since 2.5.0
652            *
653            * @see wp_get_attachment_metadata()
654            *
655            * @param WP_Post $post       The WP_Post object.
656            * @param array   $attachment An array of attachment metadata.
657            */
658           $post = apply_filters( 'attachment_fields_to_save', $post, $attachment );
659
660           if ( isset($attachment['image_alt']) ) {
661                $image_alt = wp_unslash( $attachment['image_alt'] );
662                if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) {
663                     $image_alt = wp_strip_all_tags( $image_alt, true );
664
665                     // Update_meta expects slashed.
666                     update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
667                }