admin管理员组文章数量:1315258
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 badges2 Answers
Reset to default 1Use 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
本文标签: functionsWhy are image thumbnails cropped proportionally (not per dimensions)
版权声明:本文标题:functions - Why are image thumbnails cropped proportionally (not per dimensions)? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741979007a2408288.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论