wp_upload_media
Uploads a local image file to the site's media library with optional alt text. Supports JPG, PNG, GIF, WebP up to 10 MB; defaults to dry-run, pass allow_prod to upload.
Instructions
Upload a LOCAL image file into a site's media library, with optional alt text.
file_path is a path on the machine running this server (not a URL). Images only:
.png/.jpg/.jpeg/.gif/.webp, max 10 MB; .svg is refused (script vector). The
filename is sanitized and the directory dropped. DEFAULTS TO dry_run=true (returns
a preview: filename/mime/bytes; uploads nothing). Pass dry_run=false to upload -
the returned url is what you feed to an {kind:'image'} block in wp_create_content
or wp_edit_page. Requires the REST transport. Prod writes require allow_prod=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alt | No | ||
| dry_run | No | ||
| install | Yes | ||
| file_path | Yes | ||
| allow_prod | No |