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
2 Answers
Reset to default 0It 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
版权声明:本文标题:customization - How to make image uploads default to full size? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738717087a2108540.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论