diff --git a/src/wp-admin/includes/class-wp-site-icon.php b/src/wp-admin/includes/class-wp-site-icon.php
index ff417718f6..6f4dad74b7 100644
a
|
b
|
class WP_Site_Icon { |
91 | 91 | $size = wp_getimagesize( $cropped ); |
92 | 92 | $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; |
93 | 93 | |
| 94 | $sanitized_post_title = sanitize_file_name( $parent->post_title ); |
| 95 | $use_original_title = ( |
| 96 | ( '' !== trim( $parent->post_title ) ) && |
| 97 | /* |
| 98 | * Check if the original image has a title other than the "filename" default, |
| 99 | * meaning the image had a title when originally uploaded or its title was edited. |
| 100 | */ |
| 101 | ( $parent_basename !== $sanitized_post_title ) && |
| 102 | ( pathinfo( $parent_basename, PATHINFO_FILENAME ) !== $sanitized_post_title ) |
| 103 | ); |
| 104 | $use_original_description = ( '' !== trim( $parent->post_content ) ); |
| 105 | |
94 | 106 | $attachment = array( |
95 | 107 | 'ID' => $parent_attachment_id, |
96 | | 'post_title' => wp_basename( $cropped ), |
97 | | 'post_content' => $url, |
| 108 | 'post_title' => $use_original_title ? $parent->post_title : wp_basename( $cropped ), |
| 109 | 'post_content' => $use_original_description ? $parent->post_content : $url, |
98 | 110 | 'post_mime_type' => $image_type, |
99 | 111 | 'guid' => $url, |
100 | 112 | 'context' => 'site-icon', |
101 | 113 | ); |
102 | 114 | |
| 115 | // Copy the image caption attribute (post_excerpt field) from the original image. |
| 116 | if ( '' !== trim( $parent->post_excerpt ) ) { |
| 117 | $attachment['post_excerpt'] = $parent->post_excerpt; |
| 118 | } |
| 119 | |
| 120 | // Copy the image alt text attribute from the original image. |
| 121 | if ( '' !== trim( $parent->_wp_attachment_image_alt ) ) { |
| 122 | $attachment['meta_input'] = array( |
| 123 | '_wp_attachment_image_alt' => wp_slash( $parent->_wp_attachment_image_alt ), |
| 124 | ); |
| 125 | } |
| 126 | |
103 | 127 | return $attachment; |
104 | 128 | } |
105 | 129 | |