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

functions - Why are image thumbnails cropped proportionally (not per dimensions)?

programmeradmin1浏览0评论

For some reason WordPress is ignoring my thumbnail sizes and keeping thumbnails cropped proportionately instead of specific dimensions. Here is what I have in functions.php:

add_image_size( 'main-thumbnail', 728, 410, true );

and in content.php:

<div class="thumbnail">
    <a href="<?php the_permalink(); ?>">
       <?php the_post_thumbnail( 'main-thumbnail' ); ?>
    </a>
</div>

I added these two things and regenerated my images with the Regenerate Thumbnails plugin, but it doesn't seem to matter. The images don't change.

For some reason WordPress isn't recognizing the hard crop and is keeping the images proportional, so some of my images are way taller than 410 pixels. Why is this?

For some reason WordPress is ignoring my thumbnail sizes and keeping thumbnails cropped proportionately instead of specific dimensions. Here is what I have in functions.php:

add_image_size( 'main-thumbnail', 728, 410, true );

and in content.php:

<div class="thumbnail">
    <a href="<?php the_permalink(); ?>">
       <?php the_post_thumbnail( 'main-thumbnail' ); ?>
    </a>
</div>

I added these two things and regenerated my images with the Regenerate Thumbnails plugin, but it doesn't seem to matter. The images don't change.

For some reason WordPress isn't recognizing the hard crop and is keeping the images proportional, so some of my images are way taller than 410 pixels. Why is this?

Share Improve this question edited Oct 15, 2020 at 6:30 Jesse Nickles 7357 silver badges19 bronze badges asked Jun 1, 2016 at 0:59 5AMWE5T5AMWE5T 1491 silver badge7 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Use this plugin to regenerate the images and check the posts . also check with inspect element to see if the images has 728x410 at the end after the regenerating .https://wordpress/plugins/regenerate-thumbnails/

You might wanna try registering image sizes using after_setup_theme action hook.

add_action('after_setup_theme', function() {
  add_image_size('main-thumbnail', 728, 410, true);
});

Also, if you have access to the Wordpress CLI, it is way better for regenerating images - wp media regenerate and you can also check all your registered sizes with wp media image-size

发布评论

评论列表(0)

  1. 暂无评论