在主题的 functions.php 文件中加入下面的代码:
/**
* WordPress 设置文章插入图片的默认显示方式(尺寸/对齐方式/链接)
* https://www.codesou.cn/
*/
add_action( 'after_setup_theme', 'default_attachment_display_settings' );
function default_attachment_display_settings() {
update_option( 'image_default_size', 'medium' );//设置图片的尺寸为 medium
update_option( 'image_default_align', 'center' );//设置图片的对齐方式为 center
update_option( 'image_default_link_type', 'none' );//设置图片的默认链接为 none
}
参数说明:
1.image_default_size
图片默认尺寸,可以在“设置”-“媒体”中调整参数代表的值
thumbnail
(小)、medium
(中)、large
(大)、full
(全尺寸)
2.image_default_align
图片默认对齐方式
left
(左)、right
(右)、center
(居中)none
(无)、
3.image_default_link_type
图片默认链接设定
file
(文件)、post
(地址)、custom
(自定义)、none
(无)
想要了解更多内容,请持续关注码农资源网,一起探索发现编程世界的无限可能!
本站部分资源来源于网络,仅限用于学习和研究目的,请勿用于其他用途。
如有侵权请发送邮件至1943759704@qq.com删除
码农资源网 » WordPress 设置文章图片的默认显示方式(尺寸/对齐方式/链接)
本站部分资源来源于网络,仅限用于学习和研究目的,请勿用于其他用途。
如有侵权请发送邮件至1943759704@qq.com删除
码农资源网 » WordPress 设置文章图片的默认显示方式(尺寸/对齐方式/链接)