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?

1 Answer 1


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...

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.