admin管理员组文章数量:1130349
We know that the_post_thumbnail() outputs the thumbnail & that the_post_thumbnail( array(100,100) ) outputs the thumbnail at a specified size.
And we know that we can use add_image_size( 'category-thumb', 300, 9999, $crop ); to add a custom image size which we can call using the_post_thumbnail('category-thumb') with scaling and cropping applied.
Is there a way to use the_post_thumbnail to crop an image when it's displayed?
set_post_thumbnail_size could help, but I'm asking specifically if there is a way to do this with the_post_thumbnail
This is relevant: the_post_thumbnail scaling not hard cropping
( if nothing's changed the answer is no )
We know that the_post_thumbnail() outputs the thumbnail & that the_post_thumbnail( array(100,100) ) outputs the thumbnail at a specified size.
And we know that we can use add_image_size( 'category-thumb', 300, 9999, $crop ); to add a custom image size which we can call using the_post_thumbnail('category-thumb') with scaling and cropping applied.
Is there a way to use the_post_thumbnail to crop an image when it's displayed?
set_post_thumbnail_size could help, but I'm asking specifically if there is a way to do this with the_post_thumbnail
This is relevant: the_post_thumbnail scaling not hard cropping
( if nothing's changed the answer is no )
Share Improve this question edited Dec 8, 2018 at 22:36 admcfajn asked Jan 10, 2018 at 3:53 admcfajnadmcfajn 1,3262 gold badges13 silver badges30 bronze badges1 Answer
Reset to default 2No, there's not a way to do this by using the_post_thumbnail(), neither it's recommended.
What you are looking for is cropping the images on the fly. This will cost heavy server resources, especially when you have a lot of images to work with.
But in theory, to do so, you can make a script that takes an image as input, crops the image using PHP, and then returns the image data without saving the actual file. But again, it's expensive.
We know that the_post_thumbnail() outputs the thumbnail & that the_post_thumbnail( array(100,100) ) outputs the thumbnail at a specified size.
And we know that we can use add_image_size( 'category-thumb', 300, 9999, $crop ); to add a custom image size which we can call using the_post_thumbnail('category-thumb') with scaling and cropping applied.
Is there a way to use the_post_thumbnail to crop an image when it's displayed?
set_post_thumbnail_size could help, but I'm asking specifically if there is a way to do this with the_post_thumbnail
This is relevant: the_post_thumbnail scaling not hard cropping
( if nothing's changed the answer is no )
We know that the_post_thumbnail() outputs the thumbnail & that the_post_thumbnail( array(100,100) ) outputs the thumbnail at a specified size.
And we know that we can use add_image_size( 'category-thumb', 300, 9999, $crop ); to add a custom image size which we can call using the_post_thumbnail('category-thumb') with scaling and cropping applied.
Is there a way to use the_post_thumbnail to crop an image when it's displayed?
set_post_thumbnail_size could help, but I'm asking specifically if there is a way to do this with the_post_thumbnail
This is relevant: the_post_thumbnail scaling not hard cropping
( if nothing's changed the answer is no )
Share Improve this question edited Dec 8, 2018 at 22:36 admcfajn asked Jan 10, 2018 at 3:53 admcfajnadmcfajn 1,3262 gold badges13 silver badges30 bronze badges1 Answer
Reset to default 2No, there's not a way to do this by using the_post_thumbnail(), neither it's recommended.
What you are looking for is cropping the images on the fly. This will cost heavy server resources, especially when you have a lot of images to work with.
But in theory, to do so, you can make a script that takes an image as input, crops the image using PHP, and then returns the image data without saving the actual file. But again, it's expensive.
本文标签: post thumbnailsUse getthepostthumbnail with Custom Size amp Crop
版权声明:本文标题:post thumbnails - Use getthe_post_thumbnail with Custom Size & Crop 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749115076a2318052.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论