Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to get the custom field data off an attachment and display it following the image tag in a page/post using the get_image_tag filter.

I'm using the same function to get the same data and display it on the attachment field as well. That works perfectly using the the_content filter so I know the function is working ok and the data is being stored and retrieved.

I feel like I'm missing something really obvious. Based on the few other questions I can find about the get_image_tag filter, it seems like there's either something buggy about its implementation or it doesn't run where it seems like it should. I can't even get it to append a string to the resulting $html variable and I don't get an error with wp_debug = true either.

The code is on Pastebin at http://pastebin.com/VRcEyYBh.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Turned out my "answer" was that I didn't really understand "get_image_tag." It only runs when you first insert an image. I was thinking that it ran every time the edit interface was loaded.

From researching and talking with others, it seems the only way to get the metabox data onto existing images is some kind of regex on the database, probably adding a shortcode around imagines that don't have a caption and do have metabox values. Fun!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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