wp_upload_image
Upload an image into the site's WordPress media library and get back the HOSTED url — drop it into a sections image widget ({type:'image', url}) when building a page/post, or swap an existing image via wp_patch_page (field image.url). Hosts the image on the site instead of hotlinking. Pass EXACTLY ONE of: image_url (any public http(s) URL — jpg/png/gif/webp/avif, up to 12MB, extension optional) or image_data (base64 bytes you already have locally — no public URL needed, e.g. a file you just read, up to 5MB; pass filename as a base-name hint, the real extension is always verified server-side). image_data is PLUGIN-TRANSPORT ONLY — SSH-connected sites must host the image publicly and use image_url instead. Requires writes enabled; plugin-connected sites need Xyle Connector v0.2.1+ for image_url, v0.9.8+ for image_data (older plugins return a clear update message).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alt | No | Optional alt text (SEO / accessibility) | |
| title | No | Optional media title | |
| site_id | Yes | The WordPress site ID | |
| filename | No | Base-name hint for image_data (e.g. 'logo'). The actual file extension is always derived server-side from the verified image type, never from this value. | |
| image_url | No | Public http(s) URL of the image to sideload into the media library | |
| image_data | No | Base64-encoded image bytes to upload directly (plugin-transport sites only). Mutually exclusive with image_url. |