This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Add Custom Fields to Media

Description

** this plugin is no longer being update. Please feel free to adopt me! **

Allows users to add custom fields to the media uploader and access those fields in template files. Great for adding copyrights etc.

Includes the following functions to help improve your website:

  • thisismyurl_get_custom_media_field( $attachment_id, $unique_field_id ) – Fetches the value
  • thisismyurl_has_custom_media_field( $attachment_id, $unique_field_id ) – Returns boolean value
  • thisismyurl_custom_media_field( $attachment_id, $unique_field_id ) – Displays the value

To use this plugin effectively, download and intall it on your WordPress blog. Next, access the settings page (Settings > Add Custom Fields to Media) and create a new custom field for your media uploads.

  • Unique ID – The unique variable name for this item. It may not contain special characaters or spaces
  • Field Title – The name you want to appear in the media uploader
  • Field Help – A descriptive message you want to appear in the media uploader

Once you’ve added a custom field, you can access it via the Media menu in WordPress or during the Add Media process of uploading a new item.

To display the information on your website, please use thisismyurl_custom_media_field( $attachment_id, $unique_field_id ).

If you would like to load the contents into a variable, please use thisismyurl_get_custom_media_field( $attachment_id, $unique_field_id )

To check if a variable exists, use thisismyurl_has_custom_media_field( $attachment_id, $unique_field_id )

In all cases the $unique_field_id is the Unique ID you specified when creating the field.

The $attachment_id is the ID of the attachment itself (not the post that you’re working with).

Updates

Updates to the plugin will be posted to http://thisismyurl.com/downloads/add-custom-fields-to-media/

Donations

If you would like to donate to help support future development of this tool, please visit http://thisismyurl.com/downloads/wordpress-plugins/

Screenshots

Installation

To install the plugin, please upload the folder to your plugins folder and active the plugin.

FAQ

How do I see the results?

Includes the following functions to help improve your website:

  • thisismyurl_get_custom_media_field( $attachment_id, $unique_field_id ) – Fetches the value
  • thisismyurl_has_custom_media_field( $attachment_id, $unique_field_id ) – Returns boolean value
  • thisismyurl_custom_media_field( $attachment_id, $unique_field_id ) – Displays the value
How do I add a photo credit to a featured image?

Here’s my code snippet for adding a photo credit directly under a featured image.

if ( thisismyurl_has_custom_media_field() ) {

    $credit_name = thisismyurl_get_custom_media_field( get_post_thumbnail_id( $post->ID ), 'credit_name' );
    $credit_url = thisismyurl_get_custom_media_field( get_post_thumbnail_id( $post->ID ), 'credit_url' );

    if ( empty( $credit_name ) )
        $credit_name = $credit_url;

    if ( !empty( $credit_url ) )
        $credit_text = '<a href="' . $credit_url . '" title="' . $credit_name . '">' . $credit_name . '</a>';
    else
        $credit_text = $credit_name;

    $credit_text =  '<div class="media-credit">' . $credit_text . '</div>';

    echo $credit_text;
}

Note that I named my Unique ID’s credit_name and credit_url in this example, and am fetching the them based on the ID returned for the Post feature image using get_post_thumbnail_id( $post->ID ).

Why does this plugin have thisismyurl_ before the function name?

Each plugin added to WordPress has the potential to conflict with the core, theme, or other plugins. To ensure this plugin adds only unique code to your website, the prefix thisismyurl_ is added to each function. thisismyurl is my personal domain, as well as my @thisismyurl alias on Twitter. If you’d like to ask me questions about the plugin, please feel free to Tweet me.

Where can I get more information, or technical support for this plugin?

Technical support is available for free from the WordPress community on wordpress.org.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Add Custom Fields to Media” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.2.5 (March 31, 2013)

  • fixed incorrectly named categories
  • removed link to website from plugin links
  • encoded and removed icon
  • added support link

1.2.1 (September 13. 2012)

  • language customization
  • renamed function for compatibility

1.2.0 (September 13. 2012)

Added functions:

  • thisismyurl_has_custom_media_field( $attachment_id, $unique_field_id ) – Returns boolean value
  • thisismyurl_custom_media_field( $attachment_id, $unique_field_id ) – Displays the value

1.0.1

  • fixed a bug in the fetch function

1.0.0

  • initial release