Code Duplication    Length = 7-9 lines in 3 locations

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

@@ 676-684 (lines=9) @@
673
		 */
674
		$post = apply_filters( 'attachment_fields_to_save', $post, $attachment );
675
676
		if ( isset($attachment['image_alt']) ) {
677
			$image_alt = wp_unslash( $attachment['image_alt'] );
678
			if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) {
679
				$image_alt = wp_strip_all_tags( $image_alt, true );
680
681
				// Update_meta expects slashed.
682
				update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
683
			}
684
		}
685
686
		if ( isset($post['errors']) ) {
687
			$errors[$attachment_id] = $post['errors'];

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

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

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

@@ 2475-2481 (lines=7) @@
2472
	if ( MEDIA_TRASH && isset( $changes['status'] ) )
2473
		$post['post_status'] = $changes['status'];
2474
2475
	if ( isset( $changes['alt'] ) ) {
2476
		$alt = wp_unslash( $changes['alt'] );
2477
		if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
2478
			$alt = wp_strip_all_tags( $alt, true );
2479
			update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
2480
		}
2481
	}
2482
2483
	if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
2484
		$changed = false;