functions - Can you put a condition on add_image_size() depending on the width of the uploaded image?

I just started to optimize the auto-scaling of images i upload on my wordpress (via Media tool). I added the desired set

I just started to optimize the auto-scaling of images i upload on my wordpress (via Media tool). I added the desired set of custom sizes, which are working just fine. In example :

add_image_size( 'og', 400, 9999 );
add_image_size( 'xxl', 300, 9999 );
add_image_size( 'xl', 200, 9999 );
add_image_size( 'l', 250, 9999 );
add_image_size( 'm', 150, 9999 );
add_image_size( 's', 100, 9999 );

But now i’m wondering if there is a way to put a condition to add_image_size() ? Is it possible to use a set of add_image size only if the uploaded image is less than 150px ?

I’m trying to avoid the creation of very small versions of images that are destined to be big. As wordpress don't scale images up, the idea is to have a rule that does something like : if the file i'm uploading has a width <= 150px then use this additional set of add_image_size().

I’m a beginner in coding so this might not be the right way to do it and i’m open to any suggestion !

Thank you

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744772482a4592843.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信