WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to show a meta box on the post edit screen, that contains a list of the images attached to the post. I need the meta box to work for new posts as they are being created. It should update dynamically when images are added to or removed from the post ( when images are added/removed as featured image, or using the "insert media" picker as single image or as part of a gallery in the content) .

I need the metabox to 'see' these events and update accordingly, before the post is published or even (manually) saved as a draft.

Is this possible?

If it is, I'd be happy to know (roughly) how to achieve it.

Links to plugins already doing this, or an explanation of the overall way of doing it.

Is there a JavaScript event I can listen to, and do I need to fire an ajax request to get the updated list of attachments, or can I get it all from the JS environment available in the post edit page?

share|improve this question

Well, i quess you do not need ajax (or if so, it isn't such a pain - follow the codex )

As I would implement this, I would bind a function to jQuery change or keyup to #tinymce or #content (for HTML display).

For removing post thumbnail, it would be as simple as adding click to #remove-post-thumbnail - maybe through live function

But, honestly, I'm not sure about adding thumbnail as I' don't know how to bind function to "onHTMLChange" (or how it would be called) of #postimagediv.

Your functions, of course, have to parse HTML to gain image sources...

share|improve this answer

Your Answer


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.