I’m using WordPress’ upload system (as explained here) on my plugin’s admin page.
I can upload an image and get this image’s URL. But i need attachment ID, image caption etc. How can i reach them?
I have an <form>
. It has 3 <input>
s .
<input type="text" value="" /> //This input will be filled, after user upload an image and click to `Insert to post` button. I can do it.
<input type="button" value="Click for upload image" />
<input type="hidden" value="" name="ID" /> //Attachment ID will come here automagically (with JavaScript, maybe?). I don't know how can i get it.
The attachment metadata stored for the image is:
If the image is attached to the post you can use get_children():
If you’re copying the article, these fields don’t exist. It would probably be easiest to add some form fields and get those values.
If you’re assuming that these images are already uploaded to WordPress and stored in wp-content, you can find the images in the wp database in wp-posts under post-type attatchment (source).
But again, the way the article has things set up, it looks like images can be uploaded from a user’s computer or another website, so it would probably be best just to ask them to fill in the fields.
HERE YOU GO. If I understood correctly, you want to get info after attachment was uploaded.
So put this code in
functions.php
file. And here you have 2 functions – one is fired after image is uploaded and displayed to edit info (or always whenever you edit attachment) and second one is fired when user clicks save on attachment.With those 2 functions you can make anything what you want to atchieve 🙂