Code Duplication    Length = 7-9 lines in 3 locations

src/wp-admin/includes/media.php 1 location

@@ 684-692 (lines=9) @@
681
		 */
682
		$post = apply_filters( 'attachment_fields_to_save', $post, $attachment );
683
684
		if ( isset($attachment['image_alt']) ) {
685
			$image_alt = wp_unslash( $attachment['image_alt'] );
686
			if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) {
687
				$image_alt = wp_strip_all_tags( $image_alt, true );
688
689
				// Update_meta expects slashed.
690
				update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
691
			}
692
		}
693
694
		if ( isset($post['errors']) ) {
695
			$errors[$attachment_id] = $post['errors'];

src/wp-admin/includes/post.php 1 location

@@ 313-320 (lines=8) @@
310
311
	// Attachment stuff
312
	if ( 'attachment' == $post_data['post_type'] ) {
313
		if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) {
314
			$image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
315
			if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) {
316
				$image_alt = wp_strip_all_tags( $image_alt, true );
317
				// update_meta expects slashed.
318
				update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
319
			}
320
		}
321
322
		$attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
323

src/wp-admin/includes/ajax-actions.php 1 location

@@ 2523-2529 (lines=7) @@
2520
	if ( MEDIA_TRASH && isset( $changes['status'] ) )
2521
		$post['post_status'] = $changes['status'];
2522
2523
	if ( isset( $changes['alt'] ) ) {
2524
		$alt = wp_unslash( $changes['alt'] );
2525
		if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
2526
			$alt = wp_strip_all_tags( $alt, true );
2527
			update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
2528
		}
2529
	}
2530
2531
	if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
2532
		$changed = false;