Quantcast
Channel: media
Viewing all articles
Browse latest Browse all 21

Creating Categories and Tags for Your WordPress Media

$
0
0

The media system in WordPress has come a long way in the last few years. It’s seen many welcome improvements.

As usual, however, it could probably be a little better. And one obvious way would seem to be adding categories and/or tags to media.

This would allow for easier management and even a little creative curation.

With that in mind, we’re going to go over a few ways you can assign categories or tags to media (such as images), and also how that might help.

featured-messy-photos

Two Solutions

As people often like non-plugin solutions, we’ll offer one here. But we’ll also offer a plugin solution that is much more powerful out of the box.  It gives you a refreshing new twist on working with your media and doing things like building galleries from it.

Enhanced Media Library Plugin

This first solution comes in the form of a plugin called the Enhanced Media Library.

That link goes to a site where you’ll need to download the plugin to your computer first and then upload it to your site.

That plugin is an improved version of another media library plugin with the same name found on WordPress.org.

We are recommending the plugin in the first link, however, because it really is an improvement.  The big difference is that this plugin lets you move images into categories in bulk – for example, choosing 20 travel photos and moving them into a “Travel” category and then choosing 30 food photos and moving them into a “Food” category.

With the other plugin, you would need to move each image one by one (and only after you’ve clicked into the edit screen).

This plugin lets you use your existing categories and/or tags, or you can easily create your own that will only be available for media.

How It Works

We’ll go over some of the basics of how the plugin works to give you an idea of its power.

There are a number of ways to assign your media to a category.

Assigning to Categories (or Tags) via the Uploader

Of course many people first upload their media via the post editor. And so when you do that, you’ll see a section on the right-hand side of the uploader/library for categories.

uploading

When you click into an image to edit it via the media library, you’ll see a similar set up with the categories (or tags) on the right hand side.


Via the Media Library List

If you have lots of images that aren’t assigned yet, or you’d like to put images into more than one category (or change their categories), then you can go to the Media Library. (Media > Library)

There you’ll see a list of all your images. But you’ll also see some new additional functionality since adding the plugin.

When you hover over an image, you’ll now see options to assign the image to the categories you have set up.

hover

If you select a number of images, you can then go to the drop-down at the top to the left of the Toggle Bulk button, choose your category, and then click Toggle Bulk.

bulk-move

This will move them into the category.

moved-images

Working with Media Categories

Working with media in the categories is just as easy as getting it into the categories.

Still in the Media Library, you may have noticed that there was a filter button that lets you see only the images in that category.

filter-by-cat

But let’s say you were looking for a photo while writing a post. If you click the media button on the post editor and go into the Media Library that way, you still have a way to filter your images.

filter-in-uploader

That makes it much easier to find the image you want. But it also makes it easier to do things like build a gallery of all your travel photos.

You’d simply need to do the following:

  • Click “Create Gallery”
  • Filter your images by category
  • Select the images you want
  • Click “Create a new gallery”
create-gallery


Code for Functions File

This second options is code for your functions file. While this isn’t as powerful as the plugin above, it may be a start for developers looking for something more stripped down.

If you place the following in your functions.php file, you will now see that attachments such as images can be assigned categories or tags. This is the same category and tag system already set up on your site.

As you’ll be changing your theme, you should probably consider creating a child theme if you haven’t already.

// add categories for attachments
function add_categories_for_attachments() {
    register_taxonomy_for_object_type( 'category', 'attachment' );
}
add_action( 'init' , 'add_categories_for_attachments' );

// add tags for attachments
function add_tags_for_attachments() {
    register_taxonomy_for_object_type( 'post_tag', 'attachment' );
}
add_action( 'init' , 'add_tags_for_attachments' );


Just Right for Heavy Duty Media Users

If you use and reuse a lot of media on your site, then categories for these attachments is a no-brainer. In fact, after you moved to media categories, you’d probably never be able to go back. It’d be like working with posts without categories or tags – possible, yes, but who would ever want to?


Viewing all articles
Browse latest Browse all 21

Latest Images

Trending Articles





Latest Images