更改默认缩略图元数据的措辞

时间:2013-12-02 作者:urok93

我想将默认缩略图元框中的措辞更改为“设置默认缩略图”,而不是“设置特色图像”。我该怎么做?

2 个回复
最合适的回答,由SO网友:Howdy_McGee 整理而成

我通常会这样做:

/** Use "Featured Image" Box As A Custom Box **/
function customposttype_image_box() {   
    remove_meta_box(\'postimagediv\', \'page\', \'side\');
    add_meta_box(\'postimagediv\', __(\'Set Dat Image\'), \'post_thumbnail_meta_box\', \'page\', \'side\');

}
add_action(\'do_meta_boxes\', \'customposttype_image_box\');

/** Change "Featured Image" box Link Text **/
function custom_admin_post_thumbnail_html( $content ) {
    global $post;
    if($post->post_type == \'page\')
    {
        $content = str_replace( __( \'Set featured image\' ), __( \'Upload dat Image\' ), $content);
        $content = str_replace( __( \'Remove featured image\' ), __( \'Remove dat image\' ), $content);
    }

    return $content;
}
add_filter( \'admin_post_thumbnail_html\', \'custom_admin_post_thumbnail_html\' );

SO网友:Ryan Koehler

使用media_view_strings 过滤默认文本。

在活动主题的function.php 文件

add_filter( \'media_view_strings\', function( $strings ) {
   $strings[\'setFeaturedImageTitle\'] = __( \'Set default thumbnail\' );
   $strings[\'setFeaturedImage\']    = __( \'Set default thumbnail\' );

   return $strings;
});
可在WordPress/wp includes/media中找到。php

结束

相关推荐