Media management in WordPress

Media management is, unfortunately, one of the weaker points of WordPress. There are some exciting changes coming for 3.3, but they don’t address some of the core deficiencies, such as the inability to attach a photo to multiple posts.

At the BDN, we don’t actually insert images into posts, because we bring content directly from WordPress into InDesign and putting images in posts would almost certainly cause problems. We’ve developed a set of functions to instead query for the images attached to posts and display those. They’re, of course, posted to Github. You can use the code as a simple plugin.

We’ve also customized the image edit screen a bit. As I think I’ve mentioned before, we don’t use the alt tag field, for example, nor do we use the alignment or image size fields, since we don’t insert images. We also wanted the caption field, which our functions use to display the caption info, to be a textarea instead of a textbox. All this was incredibly easy to do:

[php]
<?php
add_filter(‘attachment_fields_to_edit’, ‘bdn_do_image_things’, 20, 2);
function bdn_do_image_things( $fields, $post ) {

//Unset the fields we don’t need
unset( $fields[ ‘image_alt’ ] );
unset( $fields[ ‘image-size’ ] );
unset( $fields[ ‘align’ ] );

//Turn the caption field into a textarea.
$fields[‘post_excerpt’][‘input’] = ‘textarea’;

return $fields;
}
[/php]

It should be noted that changing the caption field from a text box to a textarea caused a problem with double-encoding of apostrophes and straight quotes. I’ve submitted a ticket and a patch to core, and hopefully this will be fixed in 3.3.

But this all didn’t solve the overall problem of having to reupload a photo every time we wanted to use it on a new post, even if it was in the system. We use a lot of file photos, so there was a lot of searching for the photo in WordPress, downloading it and promptly reuploading it. That was a lot of time wasted and a lot of aggravation. So today I whipped up a quick plugin to solve this.

Duplicate Images adds a link when you’re browsing the image library from a post that will copy the attachment data and attach it to the current post you’re working on. It doesn’t copy the actual image — that isn’t necessary. Instead it copies all the metadata over and links back to the original image so that things don’t get messy. If you decide to crop the image, for example, the meta data for the new post will change but not for the original post. It’s a pretty lightweight way to allow for attaching images to multiple posts within WordPress.

There are a few other things we do to make handling media as simple as possible in WordPress. We use Scott Bressler’s excellent Media Credit plugin to handle credits for images. We’ve extended it a bit to automatically bring in the photographer credit when uploading images (by default, it just uses whoever uploaded the photo). The code to do that, as well as to populate the caption from the Instructions field (a field we picked at random for the publishable caption) is also available on Github.

I’m very interested to hear thoughts on how everyone else manages images.

8 thoughts on “Media management in WordPress”

  1. I’ve done quite the same thing, since WP 2.0, for a local newspaper I admin ( http://www.rivieraoggi.it , and for other WP installations too):
    – avoided images in the_content;
    – print images querying for the attached ones;
    – make WP copy the attachment metadata when attaching an existing image the a post (instead of duplicating the jpg).
    I’ve done the latter using the filter ‘image_send_to_editor’ to bypass the user/journalist clicking on “Send to Post”.

    In the next weeks I think I’ll go with your plugins instead of mine, at least for the “duplicate-images” one, as for the “BDN Images” it lacks the query from other blog in the same Network that I introduced to support a twin website developed using the WP Network mode.

    Thanks for your sharing,

    P.

    P.S.: In another newspaper website I’m renewing I already used the “Zone Manager (Zoninator)”.

    1. Thanks Paolo, glad to hear what we’re posting is of some use. I would discourage you, however, from querying other blogs in the same network — switch_to_blog() is a powerful function that can cause serious performance issues. To avoid using switch_to_blog() on the live site, we instead syndicate posts from our subsites to the main site on post publish so they can be easily queried.

      Will

  2. When you say you extended the plugin to automagically bring in the credit info, do you mean from the IPTC metadata?

  3. Can you say a little more about your image management between WordPress and InDesign? Does a given story on WordPress have print-ready and web-friendly image formats/sizes attached to it, or is a single JPEG resized/reformatted via WordPress for the different end-uses? Your posts are pretty clear on the text workflow between Google Docs, WordPress and InDesign. I’d love to read similar details about the image workflow.

    1. Drew,
      We don’t have any great image workflow right now, unfortunately, though we are working on a better one. We make use of automatic toning through Amendo (http://www.onevision.com/amendo.html) and our hope is that we can automatically sync down images from WordPress, tone and size them and put them in folders to await pagination. We haven’t figured out all the details yet, though.

      In terms of sizing, InDesign actually handles resampling the image, so we plan on just sizing everything to 6 cols and then the design desk can downscale the images on the page if needed.

      I’ll post more here as we proceed.

Leave a Reply

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