-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Media: Use image default size from settings #29966
Media: Use image default size from settings #29966
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I haven't tested but it looks solid. Is there a related ticket opened in WordPress Trac?
This PR needs a rebase.
$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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there is a few places where those settings are filtered ...
Maybe, it would be better to keep them next to imageSizes
:
gutenberg/lib/editor-settings.php
Line 49 in 474bb12
'imageSizes' => $available_image_sizes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like gutenberg_get_common_block_editor_settings
isn't used for post editor. Only for site, widgets, and navigation.
I think it makes sense to keep this in the gutenberg_extend_post_editor_settings
function for now. Saying this based on DocBlocks of both functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, it's good to keep as is then. I will investigate separately what's the role of gutenberg_get_common_block_editor_settings
. FSE and Global Styles add a ton of complexity in the plugin on the PHP side until they are moved to WordPress core.
Adds new 'imageDefaultSize' block editor setting.
640231f
to
44ea521
Compare
I didn't know I should create one. Is there a contributor guideline when we should create related WordPress Trac tickets? I've rebased PR. But it looks like checks are failing for unrelated reseasons. |
I don't know if there are guidelines, but it's simple to explain. Whenever there is a PHP change that changes/extends the existing behavior in WordPress core it should be backported at some point. |
Makes sense. I will create a related Trac ticket as well. Thanks for mentioning this. |
I made a special download of the Gutenberg plugin. By going to the tab "Checks" (just below the title). I added an image and changed the Image size in the sidebar to Medium. |
Hi, @paaljoachim This PR doesn't add the feature to remember the last selected image size. Instead, it will use user-specified image default size from settings. So it partially fixes #8663. You can test it using the following steps:
@gziolo, it looks like all the checks are passing now. Is it okay to merge this? |
Yep, good to go based on your previous comment clarifying the behavior. |
Core track ticket: https://core.trac.wordpress.org/ticket/52896. |
@Mamaduka you're my hero. |
Related: WordPress/gutenberg#29966 Add new imageDefaultSize value to block editor settings. Props Mamaduka. Fixes #52896. git-svn-id: https://develop.svn.wordpress.org/trunk@50570 602fd350-edb4-49c9-b593-d223f7449a82
Related: WordPress/gutenberg#29966 Add new imageDefaultSize value to block editor settings. Props Mamaduka. Fixes #52896. git-svn-id: https://develop.svn.wordpress.org/trunk@50570 602fd350-edb4-49c9-b593-d223f7449a82
Related: WordPress/gutenberg#29966 Add new imageDefaultSize value to block editor settings. Props Mamaduka. Fixes #52896. Built from https://develop.svn.wordpress.org/trunk@50570 git-svn-id: http://core.svn.wordpress.org/trunk@50183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Related: WordPress/gutenberg#29966 Add new imageDefaultSize value to block editor settings. Props Mamaduka. Fixes #52896. Built from https://develop.svn.wordpress.org/trunk@50570 git-svn-id: https://core.svn.wordpress.org/trunk@50183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
👋 friends, looks like this PR introduced a regression in the native mobile block editor. A fix PR is already in the making.
Looking at the changes and the fix, I understand that the regression could have been caught by noticing that |
Hi, @hypest Sorry, that's totally my fault. I should have searched block dir manually instead of just trusting the linters. Is there documentation on how I can test the native mobile block editor? To avoid similar regression in the future. Thanks, George |
Thanks for the understanding @Mamaduka ❤️ . I think the PR description checklist item can use some rephrasing (and we'll do that in a separate PR. EDIT: here's the PR) as I understand it might not be easy to know which files are those and how one should go about checking them. Sorry for that.
I appreciate the empathy here 🙇♂️. There's this React Native based mobile Gutenberg guide linked from the Code contributions guide. It's a bit hard to reach, that's fair, but it can serve as a good starting point. On top of that, always happy to help or give a hand so feel free to ping me or @WordPress/native-mobile. Thanks! 🙇♂️ |
Bump. This continues to be a major ongoing issue. |
Hi, @feastdesignco Can you provide more details? This PR got merge into Gutenberg core a while ago, and now it should be part of WP 5.8 as well. |
Related: WordPress/gutenberg#29966 Add new imageDefaultSize value to block editor settings. Props Mamaduka. Fixes #52896. Built from https://develop.svn.wordpress.org/trunk@50570 git-svn-id: http://core.svn.wordpress.org/trunk@50183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
I think it should be available for gallery block also. |
Looks like it's functioning now. |
Description
Allows for user-defined image default size setting to be used instead of hardcoded one.
The setting will fallback to the default value, when
image_default_size
option isn't defined.Fixes #8663, #15091 and #20269.
How has this been tested?
Manually
image_default_size
option to "medium" onwp-admin/options.php
page.Types of changes
New feature
Checklist: