Appearance
Uploading AI-Generated Images to WordPress with Easy MCP AI
If you are uploading images generated by ChatGPT or another AI client, the upload method matters. Large base64 payloads can fail in tool calls, so this guide helps you choose the right method and confirm the image appears in WordPress.
In this article
Choose the Appropriate Image Upload Method
Use wp_upload_media with content_base64 only for small files, such as icons. It can fail for larger generated images because tool calls have payload constraints, and large base64 arguments are less reliable.
The content_base64 argument must contain the complete file contents encoded as Base64 (a text representation of the file), not an attachment reference, filename, partial string, or a file the client cannot access. If you see Invalid base64-encoded content., the tool did not receive a valid Base64 payload. Ask the client to provide the complete encoded file contents, or switch to one of the methods below.
For larger generated images, use wp_upload_media_from_url. This is the recommended method for image sizes that may exceed practical base64 payload limits.
Upload a Generated Image from a URL
Before you call wp_upload_media_from_url with a URL, make sure the image is available at a directly retrievable public HTTPS image URL.
- Generate or save your image so it is hosted at a public HTTPS image URL.
- Open that URL in a browser window where you are not logged in.
- Confirm the image loads directly, without a login prompt, cookie wall, or temporary access check.
- Use that public HTTPS image URL with
wp_upload_media_from_urlin your AI client.
Understand Direct File Handoff
Compatible AI clients can hand an attached file directly to wp_upload_media_from_url. Easy MCP AI securely fetches the client's temporary file URL and imports the file into the WordPress Media Library, so you do not need to host it at a public URL first or copy that temporary URL.
For this handoff, the client must pass a structured file object: file information containing both download_url (the download link) and file_id (the client's file identifier). Merely attaching an image in ChatGPT does not guarantee that the client sends this object.
If you see file must be a client file object carrying download_url and file_id, the direct file handoff did not supply the required object. Ask the client to pass the attached file through direct file handoff; do not invent or manually fill in these fields.
If your client does not support direct file handoff, continue using a directly retrievable public HTTPS image URL with wp_upload_media_from_url. Use wp_upload_media with content_base64 only for small files.
Verify the Upload
After running the upload tool, open your WordPress Media Library and confirm the new attachment appears there.
If the image does not appear or either upload error occurs, try these fallbacks in order:
- Explicitly ask your AI client: "Use direct file handoff with
wp_upload_media_from_urlto upload the attached image to my WordPress Media Library." In ChatGPT, you can also try a new conversation, attach the image again, and repeat the request. This is a retry step, not a guaranteed fix. - If the client still does not provide the required file object, use a directly retrievable public HTTPS image URL instead. Follow the anonymous-browser check above to confirm the image loads without authentication, then ask the client to upload that URL with
wp_upload_media_from_url. - If neither direct file handoff nor a public HTTPS image URL is available, save the image to your device. In your WordPress dashboard, go to Media > Add Media File, click Select Files, and choose the saved image to upload it directly. Confirm it appears in the Media Library.
To crop or resize an uploaded image, or rebuild missing thumbnail sizes, see Edit Images and Rebuild Thumbnails with AI.