WordPress无法上传大图片

WordPress 5.3新增了处理大图片的功能,目的是自动化压缩不适合网络浏览的图片。但有时上传原图是必须的,如果原图很大,那生成大尺寸压缩图片时可能会因为服务器资源不足等问题导致上传失败。有时也不是真的失败了,就是服务器超时,导致一些该有的ajax响应收不到,从用户界面看就是失败了,但图片其实传上去了。

错误提示

The server can’t process the image. This can happen if the server is busy or does not have enough resources to complete the task. Uploading a smaller image may help. Suggested maximum size is 2560 pixels.

解决方案

最直接的解决方法是禁用大图片功能,你可以选择安装插件Disable “BIG Image” Threshold,或者直接在主题的functions.php里放如下代码,其实这个插件也就是这一句代码。

add_filter( 'big_image_size_threshold', '__return_false' );

WordPress如何处理大图片

WordPress5.3版本增加了大图片处理功能,WordPress会检测上传图片的宽和高,如果其中任何一项超过2560像素,就要尝试将图片压缩到2560像素以下,并用压缩后的尺寸作为“full“ size。2560这个值可以通过filter big_image_size_threshold修改。filter定义如下,位于wp-admin/includes/image.php 283行

$threshold = (int) apply_filters( 'big_image_size_threshold', 2560, $imagesize, $file, $attachment_id );

除了禁用大图片处理,你还可以尝试:

  • 增加memory_limit
  • 增加max_execution_time
  • 检查当前上传一张图片会生成多少压缩版本,不要生成过多的版本,可以借助插件Disable Media Sizes
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
开发教程

如何从媒体库中获取图像并按 Alt 标签排序

2022-10-21 12:03:32

WordPress新闻

WordPress 6.1 将 send_headers Action 后移到准备加载文章的后面

2022-10-20 2:55:49

5 条回复 A文章作者 M管理员
  1. hello!,I really like your writing so a lot! share we keep up a correspondence extra approximately your post on AOL? I need an expert in this house to unravel my problem. May be that is you! Taking a look ahead to see you.

  2. What i do not understood is in truth how you are not actually a lot more smartly-liked than you may be now. You are very intelligent. You realize therefore significantly in the case of this topic, produced me individually imagine it from numerous numerous angles. Its like men and women don’t seem to be fascinated until it is one thing to do with Woman gaga! Your own stuffs nice. All the time care for it up!

  3. Thanks, I have recently been looking for info about this subject for a while and yours is the greatest I have discovered so far. However, what in regards to the bottom line? Are you certain in regards to the supply?

  4. Simply wish to say your article is as amazing. The clearness in your post is just nice and i could assume you’re an expert on this subject. Well with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please carry on the gratifying work.

  5. I loved as much as you will receive carried out right here. The sketch is tasteful, your authored subject matter stylish. nonetheless, you command get got an edginess over that you wish be delivering the following. unwell unquestionably come further formerly again as exactly the same nearly very often inside case you shield this hike.

个人中心
今日签到
有新私信 私信列表
搜索
赣ICP备2021010644号-1