How to Increase the File Size Limit in the WordPress Media Library

Last modified: June 17, 2020
You are here:
Estimated reading time: 2 min

WordPress comes with its own built in media library which supports numerous image, document, video and audio formats. However, while you can upload many different types of media, there will be a file size limit in place, and for some users, depending on their hosting company and WordPress installation, this can be as low as two megabytes. This limit is nothing near enough for uploading video and most audio content. Fortunately, you can usually increase this limit by editing certain files, although this may not work with certain hosts, in which case, you should contact your hosting company for further support.

1 – Editing the Theme Functions File

The easiest method is to edit the functions.php file for your currently active theme. However, this will not always work, in which case you should try one of the other methods provided.

  1. In your administrator dashboard, navigate to Appearance > Editor and open the functions.php by clicking on “Theme Functions” in the column to the right.
  2. Paste the following code at the end of the functions.php file, changing the upload_max_size and post_max_size limits in megabytes as required:

 

@ini_set( ‘upload_max_size’ , ’16M’ );

@ini_set( ‘post_max_size’, ’16M’);

@ini_set( ‘max_execution_time’, ‘300’ );

 

  1. Click on “Update File” to save your changes. If you change your theme, you will need to enter this code again in the functions.php file for the new theme.

2 – Edit the PHP.INI File

 

If your website is privately hosted, you should be able to find a file called php.ini in the root directory of your FTP server. However, on most shared hosting packages, you will need to create one yourself.

  1. Either download your existing php.ini file or create a new one using Notepad or any other text editor.
  2. Enter the following lines of code into the file, changing the values as required:upload_max_filesize = 16M

    post_max_size = 16M

    max_execution_time = 300

  3. Save the file, or if creating a new one, save it as php.ini. If you are using Notepad, be sure to select “All Files” from the dropdown box beside “Save as type,” otherwise it will save as a TXT document.
  4. Upload the new or modified file to your FTP server, placing it in the root directory.

 

3 – Edit the .htaccess File

The .htaccess file is a directory-level configuration file which should reside in the root directory of your FTP server. If you cannot find this file, your hosting company may not support it, although you can still try creating one. Using the same method as described previously, edit the contents of the .htaccess file or create a new file of this name. Paste the following code into it, modifying the size values as required:

php_value upload_max_filesize 16M

php_value post_max_size 16M

php_value max_execution_time 300

php_value max_input_time 300

Was this article helpful?
Dislike 0
Views: 16