How to limit media upload size in WordPress

As a membership associations or business networking site, giving your members the option to update their own listings can be a huge time saver. Letting your members login to make changes to their Business Directory listing is one less thing for your staff to do, plus business owners will generally include more detailed information, which is great for SEO.

One of the challenges however, with letting members update their own listings… is file size. A member may have gorgeous, branded images to add to their Business Directory listing, but if these images have not been optimized for the web, they can seriously slow down your site.

Adding too many large files to your site can cause headaches, for example: 

  • Google likes web pages that load quickly, slow loading pages can slow down your site.
  • Visitors may leave a page that loads too slowly…especially mobile users!
  • Site backup files can become large and unwieldy.

When members or other WordPress editors on your site have permission to upload images or other media files, it’s important to be thoughtful about how you set the controls for this. 

The guide below will explain the difference between uploading and embedding media files and how to limit media upload size for non-admin users on a WordPress website.

What types of media files can be uploaded to WordPress?

There are many different types of media files that can be uploaded directly to your WordPress website, including: 

  • Image files: .jpg, .png, .gif, etc.
  • Audio files: .mp3, .wav, etc.
  • Video files: mp4, .mov, etc.
  • Documents: .doc, .pdf, etc. 

See a full list of file types (external link) that can be uploaded to a WordPress website.

NOTE: For larger files sizes, it may be better to embed the media, rather than upload it directly to your site.

WordPress default media upload size

By default, the upload size in WordPress for media files (.jpg, .png, .pdf, .mp3, etc.) ranges from 2MB to 150MB. This is based a combination of WordPress settings and the limit set by your hosting company. 

To see the current upload size limit for your site, visit your WordPress dashboard,
go to Media >> Add New

limit-media-upload-size-in-WordPress-1

How do I upload media to WordPress?

Media files can be uploaded directly to a WordPress post or page, or uploaded to the Media Library of your site’s dashboard for later use.

WordPress-media-library-uploads

Once a media file has been added to your site’s media library, you can access it from the ‘Add Media’ button when you are creating or editing, pages, posts, image galleries, etc.

add-files-from-media-library-to-image-gallery

If you are using the Member Updater plugin, your members can also upload media directly to their Business Directory listing from the Business Editor page.

How do I limit media upload size for non-admin users & members?

For an association or membership site, typically even the site admin won’t need to upload files that are larger than 10MB. Especially after the site is built, you will likely not need to upload any files over 1MB, as image files that have been optimized for the web should generally be less than 50kb. 

Use the WordPress filer: upload_size_limit

A simple way to limit the size of files uploaded by any user role except the WordPress admin user, is to use the upload_size_limit filter.

Add the following code snippet by Drew Jaynes (external link), to the end of the functions.php file in your child theme. This will prevent your members from uploading large files and slowing down your website.

/**
 * Filter the upload size limit for non-administrators.
 *
 * @param string $size Upload size limit (in bytes).
 * @return int (maybe) Filtered size limit.
 */
function filter_site_upload_size_limit( $size ) {
    // Set the upload size limit to 1 MB for users lacking the 'manage_options' capability.
    if ( ! current_user_can( 'manage_options' ) ) {
        // 1 MB.
        $size = 1024 * 1000;
    }
    return $size;
}
add_filter( 'upload_size_limit', 'filter_site_upload_size_limit', 20 );

Step-by-step

  • Login to the cpanel of your website host.
  • From the file manager, locate the wp-content folder.
  • The themes folder is inside the wp-content folder and will contain both the parent and child theme.
  • Edit the functions.php file of your child them.
  • Add the code snippet to the end of the file.

NOTE: Editing your child theme ensures that your changes will not be overwritten when the theme gets updated.

There are a variety of factors that may play a role in determining the size of media files that you are able to upload to your site. If you are interested in learning more, check out this article from Kinsta on how to increase WordPress maximum upload file size (external link)

What is the difference between embedding & uploading media files?

Media files, like images, and especially audio and video files, tend to be really large. Uploading these files directly to your website can cause a serious slow down of your site.

The good news is that WordPress provides built-in options to embed files on your site instead. An embedded file ‘lives’ (is hosted) somewhere else and is simply displayed on your site.

For example, if you upload a video to your WordPress media library, that file is taking up space on your hosting server and when added to a page on your site, can cause serious slow down of the page’s performance.

On the other hand, if you upload a video to your YouTube account, that file ‘lives’ on the YouTube servers. You can then embed the video to a page or post on your site by simply pasting in the link to the video. WordPress will automatically display the video in your page without slowing down your site.

There are all kinds of media that you can embed right into a WordPress page just by pasting in a link, including: 

  • A video
  • A tweet
  • A Spotify podcast
  • A Meetup event
  • Even a TedTalk!
embed-a-tweet-in-WordPress
embed-a-Spotify-podcast-in-WordPress
embed-a-meetup-in-WordPress
embed-a-TedTalk-in-WordPress

Like this post?
Follow us on FacebookInstagram or YouTube for more WordPress membership tutorials!

Perfect for Merchant Associations, Professional Associations, Chambers of Commerce,
Business Networking groups, Visitor Bureaus, Community Arts Councils and more.

See all membership features offered by Chamber Dashboard.