First off, I want to say thank you for taking the time to even read this, I really do appreciate the help this site and it's community has given me thus far.

i have looked forever to be able to find a way to append (display inside an added div) some image meta data just below EVERY image in EVERY single post. I have found some stuff for NextGen Gallery and some other things, but that is way too much bloat, I just want to attach a div and a couple spans, with a little php thrown in there!

I am building a fairly huge magazine style website, and a lot of the images will need to be accredited to photographers who don't directly work for the site.

I have been searching for a way to do this via php, not js. I like the plugin Media Custom Fields it lets me add a couple extra lines of meta to every media file, which is perfect. I don't need any help with pulling that meta out and displaying it once I know how to append something to every image.

Meaning that, after someone can help me find out how to add stuff to all the images, i should be able to take it from there!

I know that this code does not work or make sense, but maybe some of you can figure out exactly what I need from this example, I hope! :

    add_filter('image', 'add_stuff',);
    function add_stuff($image_meta) 
            $image_meta = '';

            $author_name = get_post_meta($post->ID, "tamcf_author_name", TRUE );
            $author_website = get_post_meta($post->ID, "tamcf_author_website", TRUE);

                if (is_single() && (is_image())
                    foreach( $images as $image ) 
                        $image_meta .= '<div class="extra_image_meta"><span>' . $author_name . '</span><span>' . $author_website . '</span></div>';
            $image .= $image_meta
            return $image

That is pretty much what I need to happen, if you all can understand that!

  • just a note, I always insert my images at the "large" size. and yes I only want the snippet to append the meta to image files, no other type of media. And, at the moment until I get this figured out, I do want to add it to every image that shows up in every post without exception. Hope that stuff helps, still at a loss here!
    – Klyde
    Apr 15, 2012 at 6:24

1 Answer 1



I did not test this method, but it is not very old. It adds custom meta information to the caption section of the image, which can then be styled as needed. Again, I did not try the method, and I am not a coder, but from reading through the tutorial, it sounds like it fits your needs.

Add Custom Meta Fields to Media Attachments in WordPress

Original Answer

I think this article from wpbeginner might be exactly what you need. I have used this exact method before.

How to Add Additional Fields to the WordPress Media Uploader

  • Thanks @TravisPflanz but I mentioned above that there is a very nice little plugin that I m using that allows me to do exactly what that article does, and by the way this article: net.tutsplus.com/tutorials/wordpress/… from tuts helps to do it too. The specific problem I am having is that I want the fields to be added to EVERY image in EVERY single post. NOT just on the attachment pages or using a template tag like they suggest. I wish the answer to my question was that simple, but thank you for trying! If you have anything else, Great!
    – Klyde
    Apr 15, 2012 at 5:35
  • and actually the comment by ALLEN about 10 comments down on this page: net.tutsplus.com/tutorials/wordpress/… i think is getting close, but that is as close as I have gotten, and it isn't working yet... I hope someone can add to this a bit, I always seem to post on weekends late at night, lol! there aren't nearly as many of us active on here at those times and questions often get looked over :(
    – Klyde
    Apr 15, 2012 at 5:54
  • Just to clarify, I want to add a snippet to my functions file in my theme that does this work of adding the meta to all of the images for me
    – Klyde
    Apr 15, 2012 at 6:19
  • Sorry, I misunderstood the question originally. I found this old piece of code. I'm no coder and cannot get it to work, but it seems like it could get you a step closer. wpengineer.com/126/image-metadata-in-wordpress Apr 15, 2012 at 6:22
  • I added an update. It sounds like what you may need. Apr 15, 2012 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.