Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Yes—you can automate image creation inside WordPress, but generation, review, uploading, and responsive delivery are separate steps. The clearest WordPress-native route documented for WordPress 7.0 and later is a small plugin built on the WordPress AI Client. It asks a configured image-capable model for inline image data, shows a preview, and only then creates a Media Library attachment.
This guide explains the architecture, prerequisites, permission checks, REST routes, frontend flow, responsive-image limits, troubleshooting, and an alternative that avoids browser automation entirely.
What “automated image creation” means in WordPress
A dependable workflow has three distinct operations:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute- Generate: an external provider/model creates image data from a text prompt.
- Review and upload: your plugin previews the result and, after approval, saves it as a Media Library attachment.
- Deliver responsively: WordPress adds attachment metadata and responsive
srcset/sizesattributes when the image is used.
Keeping these stages separate prevents an unreviewed model result from being published immediately. Responsive sizing is not the same as universal compression, art direction, or complete performance optimization; those depend on your installation and theme.
#1 Best Overall
Prerequisites and capability checks
- WordPress: the demonstrated tutorial targets WordPress 7.0 or later.
- PHP: the example plugin header specifies PHP 7.4 or later.
- Node.js: Node.js 20 or later is required to build the example frontend assets.
- AI connection: a site administrator must configure a provider in Settings > Connectors, and the selected provider/model must support image generation.
- Permissions: generation and upload routes must enforce WordPress capabilities; the documented upload check uses
upload_files.
The AI Client is provider- and model-agnostic. OpenAI and Google AI are examples, not a guarantee that either is enabled on your site. Never hard-code a provider assumption: ask the client whether image-generation capability is available and hide or disable the UI when it is not.
Recommended architecture
1. A generation route
Create a plugin-specific authenticated REST route that accepts a prompt, calls wp_ai_client_prompt(), requests inline image data, and returns a preview payload to the browser. Do not save a Media Library item in this request.
2. A review screen
The browser displays the returned image and the prompt. The user can reject it, revise the prompt, or approve it. Keep the image data in a short-lived client state or a protected server-side store; do not expose provider credentials.
Recommended Free Tools
3. An upload route
A second authenticated route accepts the approved image, validates its type and size, and creates an attachment with WordPress media functions. Check current_user_can( 'upload_files' ) before processing the file.
4. Normal WordPress media output
Once the attachment exists, use standard attachment functions or the REST media endpoint for insertion. The core collection route is /wp/v2/media; it is different from your plugin’s custom generation and approval routes.
Build the plugin: a practical implementation plan
Step 1: Register a plugin and enqueue its app
Use a normal plugin header and enqueue a compiled JavaScript bundle on an admin page or block editor screen. Keep PHP 7.4-compatible syntax if you intend to match the documented example.
<?php
/**
* Plugin Name: AI Image Creator
* Requires PHP: 7.4
*/
add_action( 'admin_menu', function () {
add_media_page(
'AI Image Creator',
'AI Image Creator',
'upload_files',
'ai-image-creator',
function () {
echo '<div id="ai-image-creator-app"></div>';
}
);
} );
The menu capability is only a UI gate. The REST callbacks must repeat authorization checks because a user can call an endpoint without loading your screen.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Step 2: Check that the AI Client exists
Before registering or displaying generation controls, check that wp_ai_client_prompt exists. If it does not, show an actionable administrator message rather than a fatal error.
if ( ! function_exists( 'wp_ai_client_prompt' ) ) {
// Render an admin notice explaining that the WordPress AI Client is unavailable.
}
Also check the configured client’s capability for image generation. Capability detection is important because a connection may support text but not images, or may have no usable model configured.
Step 3: Register two protected REST routes
The exact namespace and route names are yours; the important design is the separation of responsibilities.
add_action( 'rest_api_init', function () {
register_rest_route( 'ai-image/v1', '/generate', [
'methods' => 'POST',
'callback' => 'ai_image_generate',
'permission_callback' => function () {
return current_user_can( 'upload_files' );
},
] );
register_rest_route( 'ai-image/v1', '/upload', [
'methods' => 'POST',
'callback' => 'ai_image_upload',
'permission_callback' => function () {
return current_user_can( 'upload_files' );
},
] );
} );
Use nonces for browser requests, validate the request method and content type, and return WordPress REST errors with useful status codes. Do not put provider API keys in JavaScript.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteStep 4: Generate inline image data
Your generation callback should read a prompt, reject an empty or excessive value, call the AI Client, and return only the data needed for preview. The tutorial’s key API is wp_ai_client_prompt(); the provider connection supplies the model.
Rank #3
function ai_image_generate( WP_REST_Request $request ) {
if ( ! function_exists( 'wp_ai_client_prompt' ) ) {
return new WP_Error( 'ai_client_missing', 'The WordPress AI Client is not available.', [ 'status' => 503 ] );
}
$prompt = trim( (string) $request->get_param( 'prompt' ) );
if ( '' === $prompt ) {
return new WP_Error( 'empty_prompt', 'Enter an image prompt.', [ 'status' => 400 ] );
}
// Call wp_ai_client_prompt() with an image-capable configured model
// and request inline image data. Adapt the request shape to the
// AI Client version installed on the site.
return rest_ensure_response( [
'prompt' => $prompt,
'image' => 'data:image/png;base64,...',
] );
}
The placeholder in this illustrative callback is intentional: the AI Client request arguments can change with the installed WordPress release and provider adapter. Follow the current WordPress Developer Blog implementation for the exact prompt-builder and inline-image options instead of guessing an argument name.
Step 5: Preview in the browser
A minimal browser flow posts JSON to your generation route, displays the returned data URL, and enables an approval button. Use apiFetch or fetch with a REST nonce supplied by WordPress.
async function generateImage(prompt) {
const result = await wp.apiFetch({
path: '/ai-image/v1/generate',
method: 'POST',
data: { prompt }
});
document.querySelector('#preview').src = result.image;
document.querySelector('#approve').disabled = false;
return result;
}
Show loading, timeout, and provider-error states. Let the user edit the prompt and regenerate without creating duplicate attachments.
Step 6: Upload only after approval
On approval, send the image data (or a securely stored server-side reference) to the upload route. Decode and validate the data, create a temporary file, and pass it through WordPress’s normal media handling functions. Set a meaningful title, alternative text, and caption from explicit user input rather than blindly copying the prompt.
function ai_image_upload( WP_REST_Request $request ) {
if ( ! current_user_can( 'upload_files' ) ) {
return new WP_Error( 'forbidden', 'You cannot upload files.', [ 'status' => 403 ] );
}
$data = (string) $request->get_param( 'image' );
if ( 0 !== strpos( $data, 'data:image/' ) ) {
return new WP_Error( 'invalid_image', 'Unsupported image data.', [ 'status' => 400 ] );
}
// Decode, verify the MIME type and size, create a temporary file,
// then call WordPress media-handling functions to create the attachment.
// Return the attachment ID and its generated media URLs.
}
In production, enforce an upload-size limit, allow only image MIME types you intend to serve, remove the temporary file after import, and handle duplicate submissions idempotently.
Using the Media REST API correctly
The core authenticated REST API is the general JSON interface for WordPress. Its media collection is /wp/v2/media, with collection and query parameters documented separately. Your generation route is not a replacement for that endpoint, and the core endpoint does not generate images. Use it when another authenticated client needs to list, inspect, or manage attachments after your plugin has created them.
Rank #4
Authentication, nonces, application passwords, and user capabilities must be selected for the client you are building. A server-to-server integration should keep credentials out of page source and logs.
Responsive images after upload
WordPress has supported srcset and sizes since WordPress 4.4 and creates smaller image sizes on upload. Themes can add further sizes. This lets browsers choose an appropriate candidate for the viewport, but it does not prove that every site automatically compresses images optimally, chooses the right crop, or supplies art-directed variants.
- Use the generated attachment IDs and standard WordPress image functions so metadata is created.
- Inspect the rendered HTML for
srcsetandsizes. - Define theme sizes deliberately for hero, card, and thumbnail layouts.
- Test large generated images on mobile connections; responsive selection reduces transfer size but does not fix an oversized original.
Advanced orchestration with Abilities and MCP
For a larger automation system, WordPress’s Abilities API can expose discoverable, runnable units; the AI Client supplies provider-agnostic model access; and the MCP Adapter can let an AI agent invoke registered abilities. This is useful when an agent must create images, attach them to posts, and perform additional editorial actions. It is not required for ordinary prompt-to-image generation, and it adds authentication, auditing, and approval decisions that you should design explicitly.
Reliability, security, and cost controls
- Provider limits: image generation depends on the configured provider, model availability, quotas, and its billing. WordPress does not make those costs uniform.
- Retries: retry transient network failures with backoff, but do not automatically retry a request after an unknown timeout unless you can deduplicate it.
- Auditability: record the requesting user, prompt, model connection, approval time, and attachment ID without storing provider secrets.
- Moderation: apply your site’s content policy before upload and before publication.
- Privacy: prompts and source content may leave your server for the configured provider; disclose that to users.
- Queueing: for bulk jobs, queue work outside the browser and expose job status instead of holding an admin request open.
Troubleshooting
The generation control is missing
Confirm WordPress is 7.0 or later, the AI Client is installed and loaded, a connection exists under Settings > Connectors, and that connection advertises image-generation capability. A text-only model will not satisfy the feature check.
The request returns 401 or 403
Check the REST nonce or authentication method, the logged-in account, and the upload_files capability. Verify that both custom routes have permission callbacks; securing only the admin page is insufficient.
The provider call times out
Inspect provider quotas and server time limits, return a clear retry message, and move long-running work to a queue. Do not create an attachment until the image bytes have been received and validated.
Best Value
The preview works but upload fails
Check that the decoded bytes are a permitted MIME type, below the server’s upload limit, and written to a readable temporary file. Confirm that the uploads directory is writable and that the user still has upload_files.
The image looks blurry on the site
Inspect the selected srcset candidate, theme image sizes, CSS dimensions, and the original generated resolution. Responsive image support chooses among available sizes; it cannot invent detail that was never generated.
Duplicate attachments appear
Disable the approval button after the first click, assign a client request ID, and make the upload callback idempotent. A browser retry after a network timeout must not blindly create a second attachment.
Or skip the browser setup
If your goal is simply to obtain a clean image of a WordPress page, post, or preview—not to generate new artwork—ScreenshotNeo provides a one-request screenshot API and MCP server. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—let Claude, Cursor, or another MCP client capture pages without you wiring a browser. It is not an image-generation model; it automates page capture.
Example cURL request (see the ScreenshotNeo documentation):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots a month with no card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan. Create a free ScreenshotNeo account.
Frequently Asked Questions
Does WordPress generate images without a plugin?
The documented workflow is plugin-based. WordPress core’s Media Library and responsive-image features do not by themselves establish that an image-generation provider is configured or available.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Can I use any AI model with the WordPress AI Client?
Only a configured connection and model that advertise image-generation capability can perform this workflow. The client is provider-agnostic, but capability and availability are site-specific.
Should generation and upload happen in one REST request?
Keeping them separate provides a review and approval step, limits accidental attachments, and makes retries safer.
Is ScreenshotNeo an AI image generator?
No. ScreenshotNeo captures rendered web pages or PDFs; it does not create new artwork from a text prompt.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.

