WordPress has evolved from a blogging tool to a fully fledged content management system (CMS). It wouldn’t run 70+ million websites if it didn’t have the capabilities that most people needed to manage content. One thing that I’ve learned over time is that while much remains the same, each website (I build) seems to have some unique requirement. Often that requirement has something to do with some type of media: audio, video, documents, images, etc.
Since I’ve been using WordPress since 2004, I can remember when it didn’t have any media management capabilities at all. There were all kinds of code snippets you could add to the “hacks” file to help manage images. Later plugins came out allowing you to upload and resize images, and then eventually media upload options were added to the WordPress core. The WordPress media library does a lot of things well, but it might not (exactly) do what you need it to do each and every time… without some tweaking.
Today we’ll go over all kinds of different ways to enhance, hack, and extend the capabilities of the WordPress media library.
Categories for the WordPress Media Library
Probably the #1 issue I have with the WordPress media library is the fact that you can’t categorize anything. I could never understand why at some point a category and / or tagging system wasn’t added specifically for media. The media library seems to have been designed with pages or posts in mind, and you once you upload something within a page or post it becomes “attached” to it. WordPress core coders seem to never have considered how you might manage groups of media.
Let me give you some website examples I’ve recently encountered with specific media requirements:
Recipe website: food images for recipes that need to be categorized by food type, meal type, and linked to their respective articles
Manfacturer website: images, and documents that need to be sorted by product line and downloadable by the end user in different variations (hi-res, lo-res, thumbnail)
Bank website: documents for accounts and loans for download, PDF files with properties and assets for sale, images of bank personel
Musician website: audio files and clips, video files and clips, images – all of which needed to be classified by event and date
Conference event website: images and documents that need to be categorized by speaker and event date
I could go on and on with examples, from realty websites, to auto dealership websites, hardware stores, carpet stores, temp agencies, artists, accountants, and more – they all have some type of media that needs to be managed.
The easiest way to solve this problem is by installing the Media Categories plugin.
As you can see in this image, the plugin allows you to create categories and sub-categories for uploaded media (the same as you would for posts):
Then when you add an image (or other media), you can assign it to a category on upload, or when inserting it into content:
Once you categorize your media, you can insert it into pages and posts using the gallery shortcode.
Honorable mention to Media Library Assistant which allows categorization of media, but also allows bulk editing of many attributes, such as alt tags and metadata.
You might also check out Media Features, which allows you to organize media in categories, but it has the additional ability to adjust JPEG image quality percentages, crop and resize images, and adds support for more types of file extensions.
Adding or Importing Into the Media Library
Another pet peeve of mine when creating a new WP website has to do with importing files to the media library. If you have to add a lot of files all at once, there is no good way to do that. It can also be difficult to make bulk changes at times, especially if you want to make changes to lots of posts at once (for attachments or features images).
If you use the Upload Media by Zip plugin, you can upload a zip file and import the contents into your media library all at once. You can even attach the contents to a page or post (or not). It even adds a button to upload a zip file of media from the edit screen of pages and posts.
Another plugin I like to use is Media Tools.
Here are some features at a glance:
- ability to import external images in pages/posts to the media library
- ability to automatically set a featured image (based on first image in the post)
- ability to set and manage multiple thumbnail sizes
- easily add thumbnails for your posts
- ability to regenerate all of your thumbnails (after import)
- allows you to convert from Timthumb conversion to built in WordPress image conversion
Basically you can think of this plugin as an “import script” for media. The image below shows the settings screen for setting featured images or importing external images. You’ll see at bottom you can choose to run it on all content, posts, pages, etc.
Media File Manager is another alternative for importing and/or managing media files. You can actually make sub-directories in wp-content/uploads – and move files into them (and not break any links or attachment associations).
If you’re a developer, one little known function is the media_sideload_image – which allows you to supply the URL to an image, and then download that image into the media library (and attach it to the post).
Replacing and Renaming Media Library Items
Often you have the need to rename items in the media library. Maybe it’s purely for SEO, and you need to rename dsc01234.jpg to pretty-file-name.jpg. The issue is – there’s no way to do this in WordPress, and if you rename the file in FTP the reference in the media library is lost, and you’ll break the image link in all the pages and posts it was attached to.
Enter the Rename Media plugin. It adds a simple capability, when you rename the title of a media file in the library, it automatically renames the file name of that item as well:
Another pain spot is the replacement of images. I can’t count the number of times I have had to update an image, and then upload and insert (the new version) to the website. If that image was on multiple pages, you have to then make the changes (to insert the new image) on all of the pages.
Wouldn’t it be easier if you could just “replace” one image (or document, or media file) with another? Enter the Enable Media Replace plugin. Once the plugin is activated, all you have to do is find the file to be replaced in the media library, and then upload the new version. That’s it!
Sometimes you might have to quickly change the metadata for your images (when renaming) – installing a plugin like Media Library Alt Fields allows youto edit the image alt text right from the media library screen.
Working with Media Attachments
Within WordPress you can upload media under the “Media” tab in the left sidebar, or you can “insert media” using the icon above the content editor for posts and pages. If you insert and upload media inside a post or page it gets “attached” (or associated) to that content. If you insert multiple images (or other media), you can then use the gallery shortcode to display an image gallery of all attached items. This only works for images, but you could use this hack to display PDF files and other non-image file types as well.
There is no native way to edit attachments, which is why the Unattach and Re-attach Media Attachments plugin was developed. Now you can attach media without inserting it within the edit screen of the page – you can make the changes directly from the media library screen. You can also (as the plugin implies) “unattach” and “re-attach” media files as well.
Also, another helpful thing with attachments is, you might benefit by having a meta box on the page/post edit screen that actually shows thumbnails of all the attached images (especially if there’s a lot of content). There’s a nice plugin called Gallery Metabox that gets this done.
Sometimes you can get duplicate attachments over time (not realizing you’ve uploaded the same thing multiple times). You might handle this situation with a one-off script like this one: