0

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.

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

2 Answers 2

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

0

'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/

1
  • Would the definitely make a difference? e.g. you can use the __return_* functions in filters and they don't take arguments.
    – Rup
    Commented Feb 19, 2022 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.