Commit 17670c761c for wordpress.org
commit 17670c761cfa54ccea17edf81328e4b99b2b5663
Author: andrewserong <andrewserong@git.wordpress.org>
Date: Fri Oct 16 03:31:50 2026 +0000
Editor: Skip auto-attaching media when attachment pages are enabled.
The block editor attaches unattached images in Image and Gallery blocks to the post when the post is saved. When attachment pages are enabled, attaching an image moves its attachment page to a URL under that post, and
the old attachment page URL then returns a 404.
This adds an `autoAttachMediaEnabled` setting to `get_default_block_editor_settings()`. It is `false` when the `wp_attachment_pages_enabled` option is on, and `true` otherwise. Sites can still change it with the
`block_editor_settings_all` filter.
Developed in: https://github.com/WordPress/wordpress-develop/pull/14308
Props faisalahammad, rejaulalomkhan, andrewserong, ramonopoly, padams.
Fixes #66321.
Built from https://develop.svn.wordpress.org/trunk@64385
git-svn-id: http://core.svn.wordpress.org/trunk@63535 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/block-editor.php b/wp-includes/block-editor.php
index 830e67cfce..24bdd2f6db 100644
--- a/wp-includes/block-editor.php
+++ b/wp-includes/block-editor.php
@@ -214,6 +214,11 @@ function get_default_block_editor_settings() {
'alignWide' => get_theme_support( 'align-wide' ),
'allowedBlockTypes' => true,
'allowedMimeTypes' => get_allowed_mime_types(),
+ /*
+ * Attaching media to a post moves its attachment page URL, and the old URL then returns a 404.
+ * Only attach on save when attachment pages are disabled, since they then redirect to the file.
+ */
+ 'autoAttachMediaEnabled' => ! get_option( 'wp_attachment_pages_enabled' ),
'defaultEditorStyles' => $default_editor_styles,
'blockCategories' => get_default_block_categories(),
'isRTL' => is_rtl(),
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 82a4d2d81a..236bd0d55b 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-64384';
+$wp_version = '7.2-alpha-64385';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.