Skip to content

Media Library

Manage attachments already in the WordPress Media Library, built on core attachment functions (wp_get_attachment_metadata, wp_update_post, wp_delete_attachment, …). To pull an external image into the library, use sideload-image; to search existing uploads use list-media.

get-media and update-media are enabled by default. delete-media ships disabled-by-default.

Full detail for one attachment: every registered image size (URL + dimensions), mime type, filesize, alt text, caption, description, and the raw attachment metadata.

Input: attachment_id.

Returns: { id, title, url, mime_type, filesize, alt, caption, description, sizes: { ... }, metadata: { ... } }.

Capability: edit_posts. Read-only.

Edits an attachment’s title, alt text, caption, and/or description. Only the fields you pass change, a one-call accessibility/SEO fix for library images.

Input: attachment_id plus any of title, alt, caption, description.

Returns: { id, updated: [...] }.

Capability: edit_post on the attachment.

Deletes an attachment. Destructive and effectively permanent: WordPress bypasses Trash for media unless the MEDIA_TRASH constant is defined, so on most sites the file and its database record are gone for good.

A three-way gate protects this tool:

  1. It is disabled-by-default. An admin must enable it on EMCP Tools → Tools.
  2. The caller needs delete_post on the attachment.
  3. The input must include an explicit confirm: true.

Pass force: true to skip Trash even when MEDIA_TRASH is on.

Input: attachment_id, confirm (must be true), force (optional).

Returns: { id, deleted: true, forced }.

Capability: delete_post on the attachment. Destructive.