5

WordPress上传图片出现“图像后期处理失败,请将其缩小到2500像素并重新上传”

 3 years ago
source link: https://www.daozhao.com/10070.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

WordPress上传图片出现“图像后期处理失败,请将其缩小到2500像素并重新上传”

如果您发现本文排版有问题,可以先点击下面的链接切换至老版进行查看!!!

WordPress上传图片出现“图像后期处理失败,请将其缩小到2500像素并重新上传”

今天在上传图片的时候发现了这个报错“图像后期处理失败,请将其缩小到2500像素并重新上传”,如果是英文版的话,就会报错“Post-processing of the image failed. If this is a photo or a large image, please scale it down to 2500 pixels and upload it again”。显然很容易想到这是因为图片过大导致的,现在的手机照片像素都那么高了,2M确实太少了,压缩图片也够麻烦的。

我们需要进行下列步骤修改下上传文件的大小上限:

修改php配置文件php.ini

默认php上传文件的大小是2M了,我们可以在后台的“媒体”——“上传新媒体文件”处看到 file

php.ini文件一般位于/etc/php.ini,我们需要在里面加上

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
修改wordpress的functions.php

如果修改了上面的php.ini可以直接跳过此步骤

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );
修改服务器的上传上限(已nginx为例)

修改配置文件/etc/nginx/nginx.conf 因为是要修改里面的http模块,所以不是我们常用的站点配置,比如/etc/nginx/conf.d/www.conf 在/etc/nginx/nginx.conf的http里面加入client_max_body_size 64m;

http {

        client_max_body_size 64m;
}

经过以上两个地方的调整,我们的上传文件上限已经64M了,日常用是足够了。

改完了记得重启php-fpm和nginx

systemctl restart php-fpm
systemctl restart nginx

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK