WordPress Plugin Media Library Custom Fields – Usage

Plugin Custom Options

To customize plugin options go to Settings > Media Library Custom Fields.


How to hide an options screen?

To hide options page, add this code to your theme:

function myprefix_hide_options() { return; }

add_action('abcfmlcf_hide_plugin_options_page', 'myprefix_hide_options');



How to customize the plugin from a theme?

Instead of using an options page you can customize the plugin from your theme:

function myprefix_custom_optns($optns) {

    $custom_optns = array(
        'cap2' => array(
            'hide' => false,
            'lbl' => 'My Custom Label 1'
        'cap3' => array(
            'hide' => false,
            'lbl' => 'My Custom Label 2'

    return array_merge($optns, $custom_optns);
add_filter('abcfmlcf_plugin_options', 'myprefix_custom_optns');


How to query WordPress for images and custom fields?

  • See the function abcfmlcf_get_images() located in get-images.php for a sample of usage.
  • You can call this function from your theme or plugin.
  • To see the working example, download our Thumbnail Links plugin.


Function abcfmlcf_get_images() – Overview

WordPress stores images as attachments.

  • The function required parameters are: attachment ID and image size.
  • You can provide single attachment ID or comma delimited list of IDs.
  • The function returns an associative array of image URLs and other data.
  • For multiple IDs, returned array is sorted in the same order as the comma delimited list of IDs.


How to call abcfmlcf_get_images() from a theme or plugin?

 * Sample function to add to your theme or plugin. Calls abcfmlcf_get_images()
 * @param string $attachment_ids. Attachment ID or comma delimited list of IDs. Example: '121,122,123'
 * @param string $image_size. Example: 'thumbnail'
function my_get_images( $attachment_ids, $image_size ){ 
   $attr = array(
      'include'     => $attachment_ids,
      'orderby'     => 'post__in',
      'size'        => $image_size

   //Returns associative array of image URLs and other data.
   $images = abcfmlcf_get_images($attr);

   foreach($images as $img){
        $imgUrl = $img['imgUrl'];
        $w = $img['w'];
        $h = $img['h'];
        $alt = $img['alt'];
        $linkUrl = $img['linkUrl'];
        $linkTarget = $img['linkTarget'];
        $title = $img['title'];
        $cap1 = $img['cap1'];
        $cap2 = $img['cap2'];
        $desc = $img['desc'];
        $imgID = $gImg['imgID'];

       //Add your custom code here...