Home >Backend Development >PHP Tutorial >Output thumbnail address

Output thumbnail address

巴扎黑
巴扎黑Original
2016-11-09 13:46:55880browse

//输出缩略图地址
function post_thumbnail_src() {
    global $post;
    if ($values = get_post_custom_values("thumb")) {   //输出自定义域图片地址
        $values = get_post_custom_values("thumb");
        $post_thumbnail_src = $values [0];
    } elseif (has_post_thumbnail()) {    //如果有特色缩略图,则输出缩略图地址
        $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
        $post_thumbnail_src = $thumbnail_src [0];
    } else {
        $post_thumbnail_src = '';
    };
    echo $post_thumbnail_src;
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn