justnews使用外链做缩略图

在主题functions.ph文件中第1101-1110行的

add_filter( 'wpcom_thumbnail_url', 'wpcom_thumbnail_url', 10, 4);
function wpcom_thumbnail_url($img_url, $post_id, $post_thumbnail_id, $size){
    global $options;
    $_post = $post_id ? get_post($post_id) : '';
    if(!$post_thumbnail_id && !$img_url && isset($_post->ID) && $_post->post_type == 'post'){
        $img_id = isset($options['post_thumb']) && $options['post_thumb'] ? $options['post_thumb'] : '';
        if($img_id) $img_url = wp_get_attachment_image_url( $img_id, $size );
    }
    return $img_url;
}

替换成

add_filter( 'wpcom_thumbnail_url', 'wpcom_thumbnail_url', 10, 4);
function wpcom_thumbnail_url($img_url, $post_id, $post_thumbnail_id, $size){
    global $options;
    $_post = $post_id ? get_post($post_id) : '';

     if( $values = get_post_custom_values("cao_thumbnail") ) { //输出自定义域图片地址
    $values = get_post_custom_values("cao_thumbnail");
    $post_thumbnail_src = $values [0];
   }
    return $post_thumbnail_src;
}

Leave a Reply