I'm trying to find all the meta fields that are used for an attachment: like Title, alternative text, description and caption . I've looked all over and the only one I was able to find was for an Alternative text, which is _wp_attachment_image_alt
.
I'm trying to find all the meta fields that are used for an attachment: like Title, alternative text, description and caption . I've looked all over and the only one I was able to find was for an Alternative text, which is _wp_attachment_image_alt
.
1 Answer
Reset to default 1You can easily inspect all the metadata for any post like so:
// 123 is the (attachment) post ID
var_dump( get_post_meta( 123 ) );
And in a default WordPress setup with no plugins or theme which add custom metadata to the image attachment post, the metadata you'd get are:
_wp_attached_file
— string, the image file (path and name) for the attachment post_wp_attachment_metadata
— array (serialized), the sizes for the image like 'thumbnail' (including original size), and metadata from EXIF/IPTC info._wp_attachment_image_alt
— string, the image's alternative text
As for the other details like the image title, they are in the post data (in the posts database table), so you can for example use wp_update_post()
to update these details:
post_title
— image titlepost_excerpt
— image captionpost_content
— image description