Read a media file
wp_get_mediaRetrieve a single WordPress media library attachment by ID to get its URL, title, MIME type, alt text, caption, and metadata, including image dimensions and generated sizes.
Instructions
Get one file of the media library (attachment) by id. Returns {id, title, mime, url, alt, caption, metadata}; metadata is WordPress' attachment metadata (for an image: width, height, file and the generated sizes). The caption of a password-protected file is empty for an account that may not edit it. An id that is not a media file (a post, say) returns a not-found error: posts and pages are read by wp_get_post, and wp_list_media lists the media with their ids. Needs the right to read the file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Attachment id, as wp_list_media returns it. |