有些時(shí)候我們是否發(fā)現(xiàn)編輯的WordPress插入的圖片沒(méi)有居中顯示,而且每次需要我們自己設(shè)置居中。實(shí)際上,我們也可以批量設(shè)置默認(rèn)的插入的圖片全部自動(dòng)居中,只需要這段代碼。
/** * WordPress默認(rèn)圖片居中 * http://bjj.org.cn/ */ add_action( 'after_setup_theme', 'cententimg_align_display_settings' ); function cententimg_align_display_settings() { update_option( 'image_default_align', 'center' );//居中顯示 update_option( 'image_default_link_type', 'file' );//連接到媒體文件本身 update_option( 'image_default_size', 'full' );//完整尺寸 }
這里默認(rèn)是居中的,我們也可以設(shè)置有其他的參數(shù)。
1、圖片的對(duì)齊方式 image_default_align
left:左對(duì)齊
right:右對(duì)齊
center:居中對(duì)齊
none:無(wú)
2、圖片的鏈接到 image_default_link_type
file:媒體文件本身
post:附件頁(yè)面,也就是圖片所在文章地址
custom:自定義URL
none:無(wú)
3、圖片的尺寸 image_default_size
thumbnail:縮略圖尺寸
medium:中等尺寸
full:完整尺寸
評(píng)論