From 940b52306e0ba5d27b23de6bebe382226a0ccc33 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 19 Apr 2021 10:56:57 +0200 Subject: [PATCH] Block Editor: Bring back imageDefaultSize shim for WP 5.7 --- lib/editor-settings.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/editor-settings.php b/lib/editor-settings.php index 0c8ed73d29c38..9a3b91c69a9f7 100644 --- a/lib/editor-settings.php +++ b/lib/editor-settings.php @@ -8,11 +8,20 @@ /** * Extends the block editor with settings that are only in the plugin. * + * This is a temporary solution until the Gutenberg plugin sets + * the required WordPress version to 5.8. + * + * @see https://core.trac.wordpress.org/ticket/52920 + * * @param array $settings Existing editor settings. * * @return array Filtered settings. */ function gutenberg_extend_post_editor_settings( $settings ) { + $image_default_size = get_option( 'image_default_size', 'large' ); + $image_sizes = wp_list_pluck( $settings['imageSizes'], 'slug' ); + + $settings['imageDefaultSize'] = in_array( $image_default_size, $image_sizes, true ) ? $image_default_size : 'large'; $settings['__unstableEnableFullSiteEditingBlocks'] = gutenberg_supports_block_templates(); return $settings;