最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Load url image full size in thumbnail, medium, large size

programmeradmin5浏览0评论

My website have about 1000 post with image setting thumbnail, medium, large...

<img class="size-medium" src="../test-600x337.jpg" alt="" width="600" height="337">
<img class="size-thumbnail" src="../test-100x100.jpg" alt="" width="100" height="100">
<img class="size-large" src="../test-1000x1000.jpg" alt="" width="1000" height="1000">

With function.php, how do I get it to return the URL for the original image (full sized image) because i deleted all image resize in my host.

Many thanks for your time and help.

My website have about 1000 post with image setting thumbnail, medium, large...

<img class="size-medium" src="../test-600x337.jpg" alt="" width="600" height="337">
<img class="size-thumbnail" src="../test-100x100.jpg" alt="" width="100" height="100">
<img class="size-large" src="../test-1000x1000.jpg" alt="" width="1000" height="1000">

With function.php, how do I get it to return the URL for the original image (full sized image) because i deleted all image resize in my host.

Many thanks for your time and help.

Share Improve this question edited Apr 12, 2020 at 11:22 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 12, 2020 at 11:02 tientruong0810tientruong0810 1
Add a comment  | 

1 Answer 1

Reset to default 0

According to your description, in your template, it currently fetch image with specific size such as 'thumbnail' or 'medium' and so on. You want to change that with a main control and force them to use original image, right?

If so, you may try the filter post_thumbnail_size

add_filter( 'post_thumbnail_size', 'q363844_modify_image_thumbnail_size', 10, 2 );
function q363844_modify_image_thumbnail_size( $size, $post_id ) {
    // because you want to return original, you can set it to 'large'
    return 'large';
}

But in the long run, I think it is not good for your website traffic and optimisation. You may consider to use a plugin by searching keywords regenerate thumbnail in plugin repository.

发布评论

评论列表(0)

  1. 暂无评论