在帖子编辑页面的添加媒体窗口中,上传图像时,有 4 种尺寸可用:Thumbnail
、Medium
和。默认情况下选择该选项。Large
Full Size
Full Size
我怎样才能使Large
选项默认被选中而不是Full Size
?
我认为这可以通过在函数文件中添加 PHP 代码来实现?
我刚刚从这篇文章中找到了答案: https ://wordpress.stackexchange.com/questions/66057/adding-a-custom-image-upload-size-and-making-it-selected-by-default
function my_default_image_size () {
return 'large';
}
add_filter( 'pre_option_image_default_size', 'my_default_image_size' );
我在 3.7.1 上对此进行了测试,并且可以正常工作。
Apparently, there's a row in the options
table in the database in which the value of the option_name
field is image_default_size
. If you set the option_value
field of this row to large
, then the default option will be the large size instead of the full size (if large is available for the image).
UPDATE `database_name`.`prefix_options` SET `option_value` = 'large' WHERE `prefix_options`.`option_name` = 'image_default_size';