WordPress 设置文章图片的默认显示方式(尺寸/对齐方式/链接)

在主题的 functions.php 文件中加入下面的代码:

/**
* WordPress 设置文章插入图片的默认显示方式(尺寸/对齐方式/链接)
* https://www./
*/
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 (无)

WordPress 设置文章图片的默认显示方式(尺寸/对齐方式/链接)

相关文章:

你感兴趣的文章:

标签云: