Media Credit

This plugin adds a “Credit” field to the media uploading and editing tool and inserts this credit when the images appear on your blog.

When adding media through the Media Uploader tool or editing media already in the Media Library, this plugin adds a new field to the media form that allows users to assign credit for given media to a user of your blog (assisted with autocomplete) or to any freeform text (e.g. courtesy photos, etc.).

When this media is then inserted into a post, a new shortcode surrounds the media,

, inside of any caption, with the media credit information. Media credit inside this shortcode is then displayed on your blog under your media with the class .media-credit, which has some default styling but you can customize to your heart’s content.

Feel free to get in touch with me about anything you’d like me to add to this plugin. E-mail me here.

Download — Join 996 already using this plugin

Latest version: Download Media Credit v1.1 [zip]

View on the WordPress plugin directory here: Media Credit

Installation

This section describes how to install the plugin and get it working.

The easiest way to install this plugin is to go to Add New in the Plugins section of your blog admin and search for “Media Credit”. On the far right side of the search results, click “Install.”

If the automatic process above fails, follow these simple steps to do a manual install:

  1. Extract the contents of the zip file into your /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Party.

FAQ

Q. I disabled the plugin and now unparsed

shortcodes are appearing all over my site – help!
A. Add this to your theme’s functions.php file to get rid of those pesky media-credit shortcodes:

<?php
function ignore_media_credit_shortcode( $atts, $content = null ) {
    return $content;
}
global $shortcode_tags;
if ( !array_key_exists( 'media-credit', $shortcode_tags ) )
    add_shortcode('media-credit', 'ignore_media_credit_shortcode' );
?>

Also, I’d really appreciate it if you gave me some feedback as to why you disabled the plugin.

Q. Can I display all or recent media credited to a given author?
A. Indeed, just call the template tag <?php display_author_media($author_id); ?> in your theme’s author.php (or elsewhere, if you want). The template tag has optional parameters if you want to customize the CSS or text. The default options will display thumbnails of the 10 most recent media items credited to the given user floated to the right with a width of 150px and a header of <h3>Recent Media</h3>.

These options can be changed with a more verbose call to the function: <?php display_author_media($author_id, $sidebar = true, $limit = 10, $link_without_parent = false, $header = "<h3>Recent Media</h3>", $exclude_unattached = true); ?>. This will make only the 10 most recent media items that are attached to a post display with the given header taking up the maximum width it’s afforded. Each image will link to the post in which it appears, or the attachment page if it has no parent post (unless $link_without_parent is set to false). If you don’t care about whether the media is attached to a post, change $exclude_unattached to false. This function as a whole will only display media uploaded and credited to a user after this plugin was installed.

Q. More generally, can I insert media credit information into my themes with a template tag, for instance on category pages?
A. I’m so glad you asked; you certainly can! Just call <?php get_media_credit_html($post); ?> with an attachment_id (int) or post object for an attachment to get the media credit, including a link to the author page. To echo the results, call <?php the_media_credit_html($post); ?>.

Q. Is there a template tag that just gives plain text rather than a link to the author page for users of my blog?
A. Yep! If you would prefer plain-text rather than a link for all media credit (and leaving out the separator and organization), call <?php get_media_credit($post); ?> which uses the same parameter as above. To echo the results, call <?php the_media_credit($post); ?>.

Feel free to get in touch with me about anything you’d like me to add to this list. E-mail me here.

Changelog

1.1

  • Now compatible with TinyMCE! Media credit will appear inline (i.e. below the photo) when using the Visual editor rather than as an ugly shortcode.
  • Updating media credit in the Media Library will now correctly and safely update it in an attached post, regardless of whether it’s a WP user or not

1.0.2

  • Added filter on the_author so that media credit is properly displayed in Media Library (not yet for unattached media, though – will be added in WP 3.1 hopefully)
  • Made $post parameter actually optional in template tags (used global $post if not given)

1.0.1

  • Changed post meta field from media-credit to _media_credit so that it doesn’t appear in custom fields section on Post edit page normally. Upgrade script will handle changing the key for all existing metadata.

1.0

  • Added author media rendering methods (see FAQ)
  • If media credit is edited in the Media Library, the media credit in the post to which media is attached to will now update as well!
  • Only load JS and CSS in admin on pages that need it
  • Blank credit can now be assigned to media
  • Switched rendering of media-credit shortcode credit info to div instead of span for more readable RSS feed

0.5.5

  • Switched autocomplete to an older, more stable version – should be working great now for all blogs!
  • With above, fixed loss of control of AJAX functionality in WordPress admin area
  • Default options are now correctly registered when the plugin is activated
  • Any pre-existing options will not be overwritten when activating the plugin
  • Separator and organization names on the settings page are properly escaped

0.5.1

  • Fixed autocomplete when selecting credit so that it only shows currently selectable users (particularly important for WordPress MU users).
  • Made it so that upon clicking in the Credit field the text already there will be highlighted – start typing right away!
  • Hid media credit inline with attachments if the “Display credits after post” option is enabled.

0.5

  • Initial release.

4 Responses to Media Credit

  1. Luke says:

    Hi Scott,

    Can this plugin handle the situation where multiple images are contained in a post and a different credit is required for each one? How would I display the credit for each image rather than one credit at the bottom of the post? I would like to access credits per image programatically,

    thanks!

    • Hi Luke,

      Media Credit absolutely can handle multiple images per post. See here for an example.

      What do you mean you would like to access the image credits programmatically? Do you mean that you want to display the credits yourself instead of letting the plugin display them for you? You can certainly do that as well! Take a look at the third FAQ for the plugin; you’re going to want to use < ?php the_media_credit_html($post); ?>.

      Let me know if you have any further questions or difficulty using the plugin!

      -Scott

  2. Luke says:

    Hi Scott – thanks for your reply. The difficulty we’re having seems to be that the credit is not saving to the database but reverting to the author name. Do you have any idea what might be causing that?

  3. Romeo B. says:

    I am having the same problem as Luke. Even when I fill in a new name for the credit field, it always reverts back to Admin, as that’s the username I’m signed in under. It seems that it’s not saving what’s written int the credit field. I’m using WP3.0.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>