如何在WordPress中上传大图片

Recently, one of our users asked us how they can upload large images in WordPress. Many users see an error when trying to upload larger images in WordPress. This is due to the file size limit. In this article, we will show you how to fix this and upload large images in WordPress.

最近,我们的一位用户问我们如何在WordPress中上传大图像。 尝试在WordPress中上载较大图像时,许多用户看到错误。 这是由于文件大小限制。 在本文中,我们将向您展示如何解决此问题并在WordPress中上传大图像。

Large File Size Error
为什么无法在WordPress中上传大图像? (Why You Cannot Upload Large Images in WordPress?)

Your WordPress hosting provider may have configured their servers in a way that place a reasonable limit on file upload sizes.

您的WordPress托管提供商可能已经以合理限制文件上传大小的方式配置了服务器。

You can see this limit by visiting Media » Add New page.

您可以通过访问媒体»添加新页面来查看此限制。

maximum upload file size in WordPress

If the limit is lower than the file you are trying to upload, then you will see an error like this: ‘ filename.jpg exceeds the maximum upload size for this site’.

如果该限制小于您尝试上传的文件,那么您将看到如下错误: “ filename.jpg超出了该站点的最大上传大小”

Another issue which may stop you from uploading large image files is memory limit.

另一个可能使您无法上载大图像文件的问题是内存限制。

By default, your WordPress site is allowed to use a reasonable amount of memory. When a script runs for too long and exhausts the defined memory limit, then you will see an error.

默认情况下,允许您的WordPress网站使用合理数量的内存。 当脚本运行时间过长并耗尽定义的内存限制时,您将看到错误。

If you’re encountering either of these errors, then this article will help you fix that so you can easily upload large files to WordPress.

如果您遇到这些错误中的任何一个,那么本文将帮助您解决此问题,以便您可以轻松地将大文件上传到WordPress。

在WordPress中修复图片上传大小 (Fixing Image Upload Size in WordPress)

If you want to upload large image and media files in WordPress, then here is how you will fix image upload size issue in WordPress.

如果要在WordPress中上传大型图像和媒体文件,则可以通过以下方法解决WordPress中图像上传大小的问题。

Simply add this code in your theme’s functions.php file.

只需将此代码添加到主题的functions.php文件中。


@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

This code tries to increase upload maximum filesize, post maxiumum size, and maximum execution time limits for your WordPress site. However, this may not work for some WordPress websites.

此代码尝试增加WordPress网站的最大上传文件大小,最大发布大小和最大执行时间限制。 但是,这可能不适用于某些WordPress网站。

In that case, you can try adding this code to your .htaccess file in your site’s root folder.

在这种情况下,您可以尝试将此代码添加到站点根文件夹中的.htaccess文件中。


php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

If both of these methods fail, then you can try adjusting these values using php.ini file.

如果这两种方法均失败,则可以尝试使用php.ini文件调整这些值。

The php.ini file is a configuration file used by PHP to define settings. Users on shared hosting, typically don’t have access to the main file. However, you can still create an empty php.ini in your site’s root folder using an FTP client.

php.ini文件是PHP用来定义设置的配置文件。 共享主机上的用户通常无权访问主文件。 但是,您仍然可以使用FTP客户端在网站的根文件夹中创建一个空的php.ini。

Creating a new file using FTP

Simply add this code in your php.ini file:

只需在您的php.ini文件中添加以下代码:


upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

Take a look at our guide on how to increase maximum file upload size in WordPress for more information.

请参阅有关如何增加WordPress中最大文件上传大小的指南, 获取更多信息。

您真的需要在WordPress中上传大型图像文件吗? (Do You Really Need to Upload Large Image Files in WordPress?)

Images take more time to load than text. This means that if you have large images files, then it would take longer for your website to load.

图像加载比文本花费更多的时间。 这意味着,如果您有较大的图像文件,则网站加载时间会更长。

Search engines don’t like slow websites, and your pages with huge images may not rank high in search results. This would cost you traffic and affect your business goals.

搜索引擎不喜欢慢速的网站,而且您的图片大的网页在搜索结果中的排名可能不高。 这将花费您的流量并影响您的业务目标。

We understand many photography site owners may want to upload high quality images to their site. However, high quality images can be optimized to have reasonable file sizes without losing too much quality.

我们了解许多摄影网站的所有者可能希望将高质量的图像上传到他们的网站。 但是,可以将高质量图像优化为具有合理的文件大小,而不会损失太多质量。

First we would recommend you to learn how to optimize images for web. You can reduce image file size without having to compromise on quality. You can also bulk resize images from within your WordPress admin area.

首先,我们建议您学习如何优化网络图像 。 您可以减小图像文件的大小,而不必牺牲质量。 您还可以在WordPress管理区域内批量调整图像大小

Next you should start using Envira Gallery to display images on your website. Envira beautifully displays image galleries without making your website slow. It is incredibly fast, beautiful, and works on all devices. We believe it’s the best photo gallery plugin for WordPress.

接下来,您应该开始使用Envira Gallery在您的网站上显示图像。 Envira精美地显示图像库,而不会使您的网站变慢。 它非常快,美观,并且可以在所有设备上使用。 我们认为这是WordPress最好的照片库插件

Many popular websites rely on CDN’s to serve static content like images. CDN (content delivery network) serves your images from servers located all over the world. This makes your images and rest of your website load simultaneously. It also improves your site’s SEO and user experience.

许多流行的网站都依赖CDN来提供静态内容(例如图像)。 CDN(内容交付网络)从世界各地的服务器提供图像。 这将使您的图像和网站的其余部分同时加载。 它还可以改善您网站的SEO和用户体验。

See our guide on how to install and setup WordPress CDN solution for detailed instructions.

有关详细说明,请参阅有关如何安装和设置WordPress CDN解决方案的指南。

That’s all, we hope this guide helped you learn how to upload large images in WordPress. You may also want to see our guide on how to resize and make images larger without losing quality.

仅此而已,我们希望本指南能帮助您学习如何在WordPress中上传大图像。 您可能还想查看我们的指南,该指南介绍了如何在不损失质量的情况下调整大小和使图像变大

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/beginners-guide/how-to-upload-large-images-in-wordpress/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值