admin管理员组

文章数量:1404923

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 ); 

本文标签: How to prevent resized featured images