WordPress Media Library

WordPress media library is another great feature of WordPress core. It made managing media files including images, sound tracks and videos a breeze. I remember creating a system for managing media in custom PHP CMS (Content Management System) was a nightmare for developers.

Before we go deeper in Media Library, watch below video demonstration to add/upload images to your WordPress Media Library.

[wpmudev-video video=”add-media”]

Here are steps for those who don’t want to watch the video.

  1. Go to WordPress Dashboard -> Media -> Library and click on Add New button.
  2. Simply find the media file(s) such as image(s) from your computer and drop anywhere on this page.
  3. OR click on Select Files button to browse the files and upload.
  4. Done!

WordPress Media Library

Allow .svg files in WordPress media library

By default WordPress does not allow uploading .svg files in media library. We can allow this file type by using the following code.


Allow .zip or .gzip archive files in WordPress media library

In case you want to upload .zip or .gzip archives in WordPress Media Library then you can do this by using following code snippet.


How to use the custom code snippets

Now, if you are wondering how you can actually use the above code in your website. Then don’t worry, here are two simple methods to do this.

One: You can add the above code at the very end of functions.php file of your child theme. Make sure you remove <?php tag at the line one of both snippets, since functions.php file have starting php tag already.

Two: You can also use these as mu-plugin. Must Use plugins or mu-plugin are like WordPress plugins.  But unlike regular WordPress plugins, you don’t need to activate mu-plugins. Just install and it will be enabled automatically.

If you take the mu-plugin route, you’ll want to log into your site via FTP, and go to your /wp-content/ folder via FTP, finding the folder called “mu-plugins”.

If there’s no folder with that name, then you’ll want to create one. Then, create a file inside that folder, and give the file any name you like (making sure the file has an extension of .php, e.g. example.php) and paste the code in there.

Any questions, need more files types allowed in media ? If yes then post a comment.

Submit a Comment

Your email address will not be published. Required fields are marked *