diff --git src/wp-admin/custom-header.php src/wp-admin/custom-header.php
index 8b2973fc11..71561332e0 100644
|
|
|
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
| 1187 | 1187 | $attachment_id = wp_insert_attachment( $object, $cropped ); |
| 1188 | 1188 | $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); |
| 1189 | 1189 | |
| | 1190 | // If this is a crop, save the original attachment ID as metadata. |
| | 1191 | if ( $parent_id ) { |
| | 1192 | $metadata['attachment_parent'] = $parent_id; |
| | 1193 | } |
| | 1194 | |
| 1190 | 1195 | /** |
| 1191 | 1196 | * Filters the header image attachment metadata. |
| 1192 | 1197 | * |
| … |
… |
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
| 1197 | 1202 | * @param array $metadata Attachment metadata. |
| 1198 | 1203 | */ |
| 1199 | 1204 | $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata ); |
| 1200 | | wp_update_attachment_metadata( $attachment_id, $metadata ); |
| 1201 | 1205 | |
| 1202 | | if ( $parent_id ) { |
| 1203 | | $meta = add_post_meta( $attachment_id, '_wp_attachment_parent', $parent_id, true ); |
| 1204 | | } |
| | 1206 | wp_update_attachment_metadata( $attachment_id, $metadata ); |
| 1205 | 1207 | |
| 1206 | 1208 | return $attachment_id; |
| 1207 | 1209 | } |
diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
index 2e462971e2..b8d30c9c78 100644
|
|
|
Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar |
| 953 | 953 | }) ); |
| 954 | 954 | } |
| 955 | 955 | |
| | 956 | this._filterContext(); |
| | 957 | this.get('library').on( 'add', this._filterContext, this ); |
| | 958 | |
| 956 | 959 | this.resetDisplays(); |
| 957 | 960 | }, |
| 958 | 961 | |
| … |
… |
Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar |
| 1152 | 1155 | if ( view && view.get( mode ) ) { |
| 1153 | 1156 | setUserSetting( 'libraryContent', mode ); |
| 1154 | 1157 | } |
| | 1158 | }, |
| | 1159 | |
| | 1160 | /** |
| | 1161 | * Filter out contextually created attachments (e.g. headers, logos, etc.) |
| | 1162 | * |
| | 1163 | * @since 4.9.0 |
| | 1164 | */ |
| | 1165 | _filterContext: function() { |
| | 1166 | var library = this.get('library'); |
| | 1167 | |
| | 1168 | library.set( library.filter( function( item ) { |
| | 1169 | return item.get('context') === ''; |
| | 1170 | } ) ); |
| 1155 | 1171 | } |
| 1156 | 1172 | }); |
| 1157 | 1173 | |
diff --git src/wp-includes/js/media/controllers/library.js src/wp-includes/js/media/controllers/library.js
index 89dc0f4daa..6f30cbb354 100644
|
|
|
Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar |
| 85 | 85 | }) ); |
| 86 | 86 | } |
| 87 | 87 | |
| | 88 | this._filterContext(); |
| | 89 | this.get('library').on( 'add', this._filterContext, this ); |
| | 90 | |
| 88 | 91 | this.resetDisplays(); |
| 89 | 92 | }, |
| 90 | 93 | |
| … |
… |
Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Librar |
| 284 | 287 | if ( view && view.get( mode ) ) { |
| 285 | 288 | setUserSetting( 'libraryContent', mode ); |
| 286 | 289 | } |
| | 290 | }, |
| | 291 | |
| | 292 | /** |
| | 293 | * Filter out contextually created attachments (e.g. headers, logos, etc.) |
| | 294 | * |
| | 295 | * @since 4.9.0 |
| | 296 | */ |
| | 297 | _filterContext: function() { |
| | 298 | var library = this.get('library'); |
| | 299 | |
| | 300 | library.set( library.filter( function( item ) { |
| | 301 | return item.get('context') === ''; |
| | 302 | } ) ); |
| 287 | 303 | } |
| 288 | 304 | }); |
| 289 | 305 | |
diff --git src/wp-includes/media.php src/wp-includes/media.php
index a280e3e41e..1981f3ad9a 100644
|
|
|
function wp_prepare_attachment_for_js( $attachment ) { |
| 3159 | 3159 | $response['filesizeHumanReadable'] = size_format( $bytes ); |
| 3160 | 3160 | } |
| 3161 | 3161 | |
| | 3162 | $context = get_post_meta( $attachment->ID, '_wp_attachment_context', true ); |
| | 3163 | $response['context'] = ( $context ) ? $context : ''; |
| | 3164 | |
| 3162 | 3165 | if ( current_user_can( 'edit_post', $attachment->ID ) ) { |
| 3163 | 3166 | $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID ); |
| 3164 | 3167 | $response['nonces']['edit'] = wp_create_nonce( 'image_editor-' . $attachment->ID ); |
diff --git src/wp-includes/theme.php src/wp-includes/theme.php
index 66390ff2bf..a69f4830cc 100644
|
|
|
function get_uploaded_header_images() { |
| 1214 | 1214 | $header_images[$header_index]['url'] = $url; |
| 1215 | 1215 | $header_images[$header_index]['thumbnail_url'] = $url; |
| 1216 | 1216 | $header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true ); |
| 1217 | | $header_images[$header_index]['attachment_parent'] = (int) get_post_meta( $header->ID, '_wp_attachment_parent', true ); |
| | 1217 | $header_images[$header_index]['attachment_parent'] = isset( $header_data['attachment_parent'] ) ? $header_data['attachment_parent'] : ''; |
| 1218 | 1218 | |
| 1219 | 1219 | if ( isset( $header_data['width'] ) ) |
| 1220 | 1220 | $header_images[$header_index]['width'] = $header_data['width']; |