Media Credit

Feel free to get in touch with me about anything you’d like me to add to this plugin or any feedback. We love hearing from our users! Start a thread on the plugin forum and we’ll get back to you shortly!

This plugin adds a “Credit” field when uploading media to posts and displays it under the images on your blog to properly credit the artist.

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, [media-credit], surrounds the media, inside of any caption, with the provided 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 which you can customize to your heart’s content.

You can also display all the media by an author on the author’s page. See more in the FAQ.

Download — Join 9599 already using this plugin

Latest version: Download Media Credit v2.3.3 [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 [media-credit] 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 and how it could have better suited your needs.

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); ?>.

Q. Can I link to an artist inside a media credit field?
A. You sure can. Just link to the artist’s website in the name attribute in the media-credit shortcode, found in HTML view for a post, or directly when adding an image. For example, if your post contains:

[media-credit name="Artist" align="alignleft" width="300"]<img src="http://www.mysite.com/files/2010/09/image.jpg" width="300" height="450" class="size-300 wp-image-2" />[/media-credit]

change it to:

[media-credit name="<a href='http://www.artistwebsite.com/'>Artist</a>" align="alignleft" width="300"]<img src="http://www.mysite.com/files/2010/09/image.jpg" width="300" height="450" class="size-300 wp-image-2" />[/media-credit]

Note the link to http://www.artistwebsite.com above.

(Thanks to Mike Schuerlein for this excellent question!)

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

Q. Why do I get unparsed [media-credit] shortcodes in my Facebook/Twitter/… previews with JetPack Publicize?
A. Unfortunately, this is a known bug in JetPack that can only be fixed by Automattic. As a workaround, use a different plugin for posting to social networks. Alternativel, if you make sure that you haven’t got any images with credits within the first 55 words of your article, you should be fine, too.

Changelog

2.3.3 (Oct. 26, 2014)

  • Fixed encoding bug with HTML credit lines

2.3.2 (Oct. 22, 2014)

  • Fixed editing of image classes in the visual editor

2.3.1 (Oct. 9, 2014)

  • Fixed deletion of [media-credit] shortcodes without in the visual editor
  • Fixed bug that added to apostrophes/single quotes in certain circumstances

2.3.0 (Sep. 18, 2014)

  • Code clean-up
  • Added support for visual editing of shortcodes
  • Fixed edited posts not updating when credits are changed via the media modal.
  • Added FAQ regarding unparsed shortcodes with JetPack Publicize

2.2.3 (Sep. 10, 2014)

  • Add plugin version to CSS & JS files to ensure the autocomplete bugfix is applied.

2.2.2 (Sep. 6, 2014)

  • Fixed long-standing bug with saving autocompleted credits
  • Fixed missing autocomplete in WP 4.0 media grid

2.2.1 (Sep. 4, 2014)

  • Fixed E_NOTICE level error message

2.2.0 (Sep. 4, 2014)

  • Added option to prevent attachment authors as default credit
  • Updated TinyMCE plugin for WordPress 4.0
  • Various bugfixes

2.1.2 (Aug. 12, 2014)

  • Fixed a packaging error that rendered the plugin inoperational

2.1.1 (Aug. 11, 2014)

  • Fix Visual Editor mode when credit field is empty

2.1.0 (Apr. 16, 2014)

  • Compatibility with WordPress 3.9 (TinyMCE 4.x)
  • Completely new Visual Editor code

2.0.1 (Oct. 29, 2013)

  • Bumped version number to fix update notice for users of 1.1.2

2.0 (Oct. 27, 2013)

  • Compatibility with WordPress 3.5 media dialog
  • Fixes for bugs in Visual editor
  • Fixed shortcode parsing (broken since WordPress 3.4)

1.1.2 (Mar. 1, 2011)

  • Fixes total autocomplete failure on WordPress 3.1
  • Fixes freeform credit situation where a user was selected but freeform text was entered afterward
  • Fixes extra output on activation notices (they weren’t serious, but I imagine some people were freaking out seeing them)

1.1.1 (Sep. 19, 2010)

  • Updating media credit in the Media Library really does update the credit within posts correctly now! (props: Greg Wrey)
  • Adding multiple images with freeform media credit to a post also now works as expected (props: Greg Wrey)

1.1 (Jun. 25, 2010)

  • 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 (May 3, 2010)

  • 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 (Apr. 26, 2010)

  • 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 (Apr. 26, 2010)

  • 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 (Mar. 9, 2010)

  • 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 (Mar. 5, 2010)

  • 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 (Mar. 4, 2010)

  • Initial release.

28 thoughts on “Media Credit

  1. Luke

    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!

    Reply
    1. Scott Bressler Post author

      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

      Reply
  2. Luke

    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?

    Reply
  3. Romeo B.

    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.

    Reply
  4. CArl

    Hello,

    It seems that there is now a problem with the media credit plug. When attempting to edit a post that I have used the plug tag with, the entire post is not showing up in the edit window when using VISUAL view, however; the post will show up under HTML view with codes.

    After disabling the plug, the posts reappear in VISUAL view.

    Suggestions?

    Reply
  5. Francesco

    I think one thing is missing for this excellent plugin: the ability to add a custom field with a link for the custom credit. In other words, I would like to be able to add to pictures a custom credit name and a custom link, not only a custom credit name.

    Regards, Francesco.

    Reply
    1. Scott Bressler Post author

      Thanks for this excellent bit of feedback! Coincidentally, I actually got the same request from someone else this week and added the answer to the FAQ for the plugin above.

      Here’s the relevant section:

      Can I link to an artist inside a media credit field?

      You sure can. Just link to the artist’s website in the name attribute in the media-credit shortcode, found in HTML view for a post, or directly when adding an image. For example, if your post contains:

      [media-credit name="Artist" align="alignleft" width="300"]<img src="http://www.mysite.com/files/2010/09/image.jpg" width="300" height="450" class="size-300 wp-image-2" />[/media-credit]

      change it to:

      [media-credit name="<a href='http://www.artistwebsite.com/'>Artist</a>" align="alignleft" width="300"]<img src="http://www.mysite.com/files/2010/09/image.jpg" width="300" height="450" class="size-300 wp-image-2" />[/media-credit]

      Note the link to www.artistwebsite.com above.

      I’m considering making this easier so people who don’t know HTML can do this as well, and I will let you know if I begin working on another approach. However, for now, this should hopefully suffice. Always open to feedback!

      Reply
  6. Brian Robertson

    Ok Scott, I love the concept of this plugin! What do you think about in the settings being able to set a custom “Media Credit Phrase” – just leave it blank if you don’t want to use it – and also a “Link Target”. And then with each image have the following options: “Photographer” and “Photographer’s Site” – or something like that. Then, beneath the image it adds (my php probably isn’t correct, but you’ll get the point):

    <?php echo (Media Credit Phrase) & " " & (Photographer) & "/>"; ?>

    Example: “Photo provided by Bald Brian

    Reply
  7. eddie

    Hi Scott,

    Love the concept of your plugin. I can’t get it to work though. Like some of the above posters, the name I enter reverts to the post author’s name upon saving. I’m running 1.1.1.

    Thanks,
    Eddie

    Reply
    1. Scott Bressler Post author

      Hi Eddie,

      I’m sorry to hear about your troubles with the plugin. What version of WP are you using? Does the issue happen every time you try to give credit to users? Does it only happen for users of your blog, or only for “freeform” credits, or does it happen for any and all credit you try to attribute?

      -Scott

      Reply
  8. Harry Underwood

    First off, I wanted to say that this plugin is extremely useful to my current job, as I did not have a proper means of attaching names to images as well as posts before this and Post Author Box. I am glad for both plugins’ existences.

    That said, I also wanted to ask if it is possible to further integrate Media Credit into the TinyMCE image capabilities in WordPress. When one wants to edit an image in a post (say, for size and external linking), Media Credit is conspicuously missing from among the options of editing the attributes of images (but not from when one wants to upload an image or go into the gallery of already uploaded images). Also, I wonder if NextGEN Gallery’s makers could benefit from your contribution.

    Once again, I love this plugin, and wish I had come across it sooner! Thank you!

    Reply
  9. Gregg

    I have the same issue mentioned above running Media Credit v1.1.2 and WP v3.1.2. I insert the template tag for plain text into single.php. However, the credit below the image reverts to the post author and not the plain text I have in the credit field in my media library.

    Interestingly, the author field in the media library listing reflects the value of the credit field correctly so I suspect that the value of $post refers to the post as opposed to the attachment. I don’t know enough PHP to figure it out, but I would love to get this working correctly.

    Any thoughts?

    Reply
  10. Andy M

    Trying to attach the credit to individual photos. Done so in the upload photo section however it is not showing up under the image in an article, but is at the bottom of the article. We use many articles and would rather have the credit immediately below the image – how can i do this?

    Reply
  11. Tery

    This plugin does exactly what I need, as far as adding the credit to the image and making it easy to style. However, I’m having a problem with the styling of my pre-existing caption. As far as I can tell, media-credit puts the caption in a definition list. I need to style that definition list to remove the top margin, but I can’t find where to do that. You can see an example of the problem at http://www.whetstone.wesley.edu/2011/10/24/wesley-football-team-crushes-frostburg-state-at-homecoming/ .

    I need to change:
    <dl id="attachment_2469" class="wp-caption alignright" style="width: 310px;">
    to
    <dl id="attachment_2469" class="wp-caption alignright" style="width: 310px; margin-top:0px;">
    but I can’t find where to do that. Help?

    Reply
    1. Scott Bressler Post author

      Hi Tery,

      You’ll want to do this in your theme’s CSS file rather than modifying the plugin directly. You should be able to target the images, captions, and media credit sections using the CSS classes you see above, among other tags. Just so you know, the code you posted is part of the caption, not the Media Credit, and the styling for it is coming from line 174 in custom.css in your newsport theme. Media Credit uses divs and spans only.

      Also, in your custom.css file, you specify a bunch of MC-specific styles. However, the targeting is incorrect for many of theme: .wp-caption-dt should be .wp-caption dt and so on.

      When modifying the caption styles, you might want to consider only modifying them if they immediately follow an MC div using adjacent sibling selectors, such as .media-credit-container + .wp-caption.

      Reply
      1. Tery

        Thanks, Scott. The reason I thought the definition list code was coming from media-credit is that I have two images on that page — one with media-credit and one without. The one with media credit looks like this:
        <div class="mceTemp"><div class="media-credit-container alignright" style="width: 310px"><a href="http://www.whetstone.wesley.edu/2011/10/24/wesley-football-team-crushes-frostburg-state-at-homecoming/rb-brandon-wright-breaks-the-tackle-of-34-joeseph-ross-2/&quot; rel="attachment wp-att-2469"><img class="size-medium wp-image-2469" title="Rb Brandon Wright breaks the tackle of 34 Joeseph Ross." src="http://www.whetstone.wesley.edu/wp-content/uploads/2011/10/IMG_45331-300×200.jpg&quot; alt="" width="300" height="200" /></a><span class="media-credit">The Whetstone/ Cochise Lucas</span></div><dl id="attachment_2469" class="wp-caption alignright" style="width: 310px;"><dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">Rb Brandon Wright breaks the tackle of 34 Joeseph Ross.</dd></dl></div>

        while the one without media-credit looks like this:
        <div id="attachment_2463" class="wp-caption alignleft" style="width: 210px"><a href="http://www.whetstone.wesley.edu/2011/10/24/wesley-football-team-crushes-frostburg-state-at-homecoming/img_4756-2/&quot; rel="attachment wp-att-2463"><img class="size-medium wp-image-2463" title="IMG_4756" src="http://www.whetstone.wesley.edu/wp-content/uploads/2011/10/IMG_47561-200×300.jpg&quot; alt="" width="200" height="300" /></a><p class="wp-caption-text">The Whetstone/ Cochise Lucas</p></div>

        I’ll try changing the values for the alignright class, but I’m afraid that will affect too many other places on the site. If that doesn’t work, is the solution then to find the caption processing in WordPress and add a third class, after alignright, to override that top margin?

      2. Tery

        I tried changing the top margin in alignright to 0px. That’s not fixing the problem. Also, the reason I specified .wp-caption-dt is that that’s the class associated with the dt. I thought the class would override the standard dt declaration, though I could be wrong about that. My CSS abilities are okay but not stellar.

      3. Scott Bressler Post author

        There are issues with using the “Visual” editor in WordPress 3.2 and up, so that’s likely why you have the “mceTemp” div. Try using the HTML editor.

        I’d recommend you put the navy background on something that surrounds both the media credit and the caption to ensure that there are no gray bars in between. If you can’t find anything to target with your CSS, you can surround the images yourself by filtering the_content in your functions.php file, though beware of any performance degradation.

  12. Tery

    Hi — Is this still supported? If so, I’m having a weird problem. When the media-credit plugin is active, I can’t insert images into posts. When I disable it, I can insert images again. I can’t disable it permanently because it seems to mess up the look of older posts, where we used the media-credit field, when it’s not active. So what we’re having to do is disable media-credit, insert the images into the post, then enable media-credit again. We’re running WordPress 3.5.1 with the Advanced Newspaper Theme from Gabfire.

    Reply
  13. Art Campbell

    Really delighted to see the version 2 roll out!
    I’d been kludging the 1.x by hand for probably a year or more…
    However, the 2.0 version isn’t working on my site at all. Can’t insert media into a post if anything is in the Credit field….

    Anything I can check?

    Reply
  14. Mar

    Your plugin works flawlessly. However, I am running into a situation where I’d like the thumbnails that your plugin places on my page via the template tag to be picked up by thickbox or slimbox as a gallery viewer. Is there a configuration or a php file that I can alter that will allow a thickbox plugin to pick up the thumbnails and display in a gallery rather than displaying each image on its own page?

    Reply
  15. Jon

    Thanks for creating this plugin- it works great! Only one minor issue I was wondering about. After I have added an image, the edit and remove buttons on the image in the visual editor lose all their styling and are difficult to see on darker images. Below is the difference in code before and after Media Credit is activated:

    Without Media Credit activated:

    With Media Credit activated:


    The js changes the divs to ‘p’ and ‘i’ and then the styling disappears. I know this is a minor issue, but was wondering if it could be changed so the default styling doesn’t go away. I’ve tried to override the styling, but for some reason am having trouble getting it to apply to ‘#wp-image-toolbar i’.

    Best,
    Jon

    Reply

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>