WordPress as CMS – New Features Part 2: Media Management

By Sol in Lab

Compared to other content types, media types (video, image, audio, etc.) are differentiated by certain characteristics:

  • Media files generally need to be uploaded to the server
  • They can be embedded in other content (posts)
  • They require specific markup to be displayed

It is because of these special characteristics that content types classified as media are not treated the same as other content types. For the most part, media will be added when adding another content type (an mp3 for a podcast, a thumbnail image for an article, etc.). Nonetheless, they are still treated as a separate content item (which means that they may be selected and embedded in any other content item as well).

Some differences regarding how media items are handled:

  • Upload Capability – Media files may be uploaded
  • File Organization – Media files are saved into directories based on file type
  • Embed Media in a Post – Media can be easily added to a post by clicking an “Insert Media” button, viewing a gallery of media items (sortable and filterable), and selecting the media item(s) to insert.
  • Automatic Media Viewers – When a media item is displayed, it is automatically wrapped in a the proper markup to allowing viewing. For example:
    • Images (gif, jpg, png) are wrapped in <img> tags
    • Flash Videos (flv) are wrapped in a flash video player
    • Mp3 files are wrapped in a flash-based audio player

    The nice thing is that these viewers are simply the default templates defined for each of the content types. This means that:

    1. Viewers can be easily modified
    2. Default viewers can be easily overridden via a template for further customization

Adding new media types is as simple as adding any other content types (define the characteristics of the media type, create default viewer template, and you’re done).

Personally, I like the automatic viewers for displaying media the most. This relieves template creators from having to do this task, and all they have to do is add a simple template tag (show_media(), for example).