该插件尚未通过WordPress的最新3个主要版本进行测试。 当与较新版本的WordPress一起使用时,可能不再受到维护或支持,并且可能会存在兼容性问题。

Add Custom Fields to Media

描述

** 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 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/

屏幕截图

安装

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

常见问题

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.

评价

此插件暂无评价。

贡献者及开发者

“Add Custom Fields to Media” 是开源软件。 以下人员对此插件做出了贡献。

贡献者

更新日志

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