Commit 66857bb5ab for wordpress.org
commit 66857bb5ab9bbdf01fa8471fc3cb4f5b4d9f5df4
Author: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Date: Mon Oct 19 20:01:00 2026 +0000
Editor: Add the attachment entity view config for the media editor.
Adds the view config of the `attachment` post type. Its form is the one of the media editor: the editable fields (title, alt text, caption, and description) in a regular layout, then the date, author, file name, MIME type, file size, dimensions, and "Attached to" fields in panels. Only the form is replaced; the default view, the layouts, and the list view stay the ones `wp_get_entity_view_config()` builds for every post type.
Without it, the media editor falls back to the default post type form, and the "Details" tab of the "Edit image" modal shows only the date and the author.
Developed in https://github.com/WordPress/wordpress-develop/pull/14513.
Synced from https://github.com/WordPress/gutenberg/pull/84700.
Props jorgefilipecosta, oandregal.
See #66229.
Built from https://develop.svn.wordpress.org/trunk@64567
git-svn-id: http://core.svn.wordpress.org/trunk@63717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
index d2fb5d59a8..c962b962fa 100644
--- a/wp-includes/default-filters.php
+++ b/wp-includes/default-filters.php
@@ -841,7 +841,7 @@ add_filter( 'rest_pre_insert_wp_template', 'inject_ignored_hooked_blocks_metadat
add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' );
// View Config API.
-foreach ( array( 'page', 'wp_block', 'wp_template_part', 'wp_template' ) as $post_type ) {
+foreach ( array( 'page', 'wp_block', 'wp_template_part', 'wp_template', 'attachment' ) as $post_type ) {
// Base definitions run before the default priority, so third-party
// callbacks registered at the default compose on top of them
// regardless of registration order.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 213f83022c..b3005feabf 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-64566';
+$wp_version = '7.2-alpha-64567';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
diff --git a/wp-includes/view-config.php b/wp-includes/view-config.php
index bf10553500..ebf3dd3dc5 100644
--- a/wp-includes/view-config.php
+++ b/wp-includes/view-config.php
@@ -771,6 +771,61 @@ function _wp_get_entity_view_config_posttype_wp_template( $data ) {
return $data;
}
+/**
+ * Provides the view configuration for the `attachment` post type.
+ *
+ * An attachment is edited through a form (the media editor) that shares
+ * nothing with the default post type form, so the `form` is replaced: the
+ * editable fields first, in a regular layout, then the metadata and the file
+ * information, in panels. The generic `default_view`, `default_layouts`, and
+ * `view_list` built by wp_get_entity_view_config() are left untouched.
+ *
+ * @since 7.2.0
+ *
+ * @param WP_View_Config_Data $data The view configuration container for the entity.
+ * @return WP_View_Config_Data The updated view configuration container.
+ */
+function _wp_get_entity_view_config_posttype_attachment( $data ) {
+ $regular_layout = array(
+ 'type' => 'regular',
+ 'labelPosition' => 'top',
+ );
+
+ return $data->set(
+ array(
+ 'form' => array(
+ 'layout' => array( 'type' => 'panel' ),
+ 'fields' => array(
+ array(
+ 'id' => 'title',
+ 'layout' => $regular_layout,
+ ),
+ array(
+ 'id' => 'alt_text',
+ 'layout' => $regular_layout,
+ ),
+ array(
+ 'id' => 'caption',
+ 'layout' => $regular_layout,
+ ),
+ array(
+ 'id' => 'description',
+ 'layout' => $regular_layout,
+ ),
+ 'date',
+ 'author',
+ 'filename',
+ 'mime_type',
+ 'filesize',
+ 'media_dimensions',
+ 'attached_to',
+ ),
+ ),
+ ),
+ 1
+ );
+}
+
/**
* Provides the view configuration for the `root`/`site` entity.
*