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

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

share|improve this answer

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.