admin管理员组

文章数量:1208155

I want to make it so that when an image is added to a post, full size is selected by default. It currently defaults to large.

I have tried:

function my_set_default_image_size () {
    return 'full';
}
add_filter( 'pre_option_image_default_size', 'my_set_default_image_size' );

and

add_filter('pre_option_image_default_size', function() { return 'full'; });

but neither are working for me.

I'm on WordPress 5.0.3, using the block editor.

I want to make it so that when an image is added to a post, full size is selected by default. It currently defaults to large.

I have tried:

function my_set_default_image_size () {
    return 'full';
}
add_filter( 'pre_option_image_default_size', 'my_set_default_image_size' );

and

add_filter('pre_option_image_default_size', function() { return 'full'; });

but neither are working for me.

I'm on WordPress 5.0.3, using the block editor.

Share Improve this question edited Feb 20, 2019 at 20:39 ChristinaO asked Feb 20, 2019 at 14:48 ChristinaOChristinaO 11 bronze badge 2
  • are you using the classic editor or the block editor? – Tom J Nowell Commented Feb 20, 2019 at 15:38
  • @TomJNowell the block editor – ChristinaO Commented Feb 21, 2019 at 17:39
Add a comment  | 

2 Answers 2

Reset to default 0

It doesn't look like that filter exists in WordPress core. That being said, I have the solution for you. That select uses an option to set the default size:

get_option( 'image_default_size', 'medium' );

So all you have to do is update that option:

update_option( 'image_default_size', 'full' );

For reference: media.php line 1296

'pre_option_image_default_size' is ok, but your functions needs to receive a param

add_filter('pre_option_image_default_size', function($param) { return 'full'; });

See pre_option_{$option} hook.

https://developer.wordpress.org/reference/hooks/pre_option_option/

本文标签: customizationHow to make image uploads default to full size