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

How to prevent resized featured images?

programmeradmin2浏览0评论

The theme has set thumbnail sizes for featured images:

    add_theme_support( 'post-thumbnails' );
add_image_size( 'hitmag-landscape', 1120, 450, true );
add_image_size( 'hitmag-featured', 735, 400, true );
add_image_size( 'hitmag-grid', 348, 215, true );
add_image_size( 'hitmag-list', 290, 220, true );
add_image_size( 'hitmag-thumbnail', 135, 93, true );

How do I set the "featured" image one so that the image size is just whatever image I upload (for height - I want to be able to set width to 735 still)

The theme has set thumbnail sizes for featured images:

    add_theme_support( 'post-thumbnails' );
add_image_size( 'hitmag-landscape', 1120, 450, true );
add_image_size( 'hitmag-featured', 735, 400, true );
add_image_size( 'hitmag-grid', 348, 215, true );
add_image_size( 'hitmag-list', 290, 220, true );
add_image_size( 'hitmag-thumbnail', 135, 93, true );

How do I set the "featured" image one so that the image size is just whatever image I upload (for height - I want to be able to set width to 735 still)

Share Improve this question edited Jan 8, 2019 at 23:29 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Jan 8, 2019 at 17:52 MantaRayMantaRay 254 bronze badges 1
  • If u dont want to crop image than you can change true to false in this line add_image_size( 'hitmag-featured', 735, 400, true ); – Pratik Patel Commented Jan 8, 2019 at 18:04
Add a comment  | 

1 Answer 1

Reset to default 1

Featured image sizes are mostly likely controlled by your theme, so I would look there. Maybe there is a theme setting for it.

You can also check the following setting to see if it us using one of those sizes.


You can change the featured image size by adding this code into your functions.php file. More info on set_post_thumbnail_size.

set_post_thumbnail_size( 500, 500 );

You can also add a new image size and then use it in your template by doing something like this...

add_image_size( 'featured-image-size', 800, 9999 ); // Add to functions.php
php the_post_thumbnail( 'featured-image-size' ); // Template usage

More info on add_image_size & the_post_thumbnail


Edit: Since you updated your question, here is an updated answer.

You can set the height to be unlimited like this...

add_image_size( 'hitmag-featured', 735, 9999 ); 
发布评论

评论列表(0)

  1. 暂无评论