WordPress plugin that adds AI-powered image generation to both Classic Editor and Block Editor (Gutenberg). Generate professional blog hero images using multiple AI models via OpenRouter without leaving your post editor.
- Dual Editor Support: Works in both Classic Editor and Block Editor (Gutenberg)
- Block Editor Sidebar Panel: Dedicated "AI Generate" panel in Document settings
- Classic Editor Modal Tab: "AI Generate" tab in media library modal
- Auto Prompt Generation: Automatically creates image prompts from your post title, content, and category
- Style Presets: 5 editorial presets (Photorealistic, Tech/Business, Lifestyle, News/Journalism, Creative/Artistic)
- Dynamic Model Selection: Choose which AI models to enable from available OpenRouter image models
- Multiple Image Options: Generates images from each enabled model for comparison
- Category Presets: Different image styles for different post categories
- One-Click Generation: From blank post to featured image in seconds
- Media Library Upload: Generated images automatically added to your media library
- Download the latest release from Releases
- Upload the ZIP file via WordPress Admin → Plugins → Add New → Upload Plugin
- Activate the plugin
- Go to Settings → AI Image Generator to configure your API key
- Clone or download this repository
- Upload the
wp-ai-image-genfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Go to Settings → AI Image Generator to configure your API key
- Go to https://openrouter.ai/keys
- Create a new API key
- Copy the key (starts with
sk-or-...) - Add credits to your account ($5-10 recommended)
- In WordPress admin, go to Settings → AI Image Generator
- Paste your OpenRouter API key
- Select your preferred AI model (default: Google Gemini 2.5 Flash Image)
- Set number of images to generate (default: 3)
- Customize brand guidelines to match your site's style
- Optional: Add category-specific style presets
- Click Save Changes
Define your brand style that will be applied to all generated images. Example:
blue gradient, modern tech aesthetic, clean minimalist design, no text overlays
Customize this to match your brand colors and style!
- Create or edit a post in the Block Editor
- Open the Document sidebar (right side)
- Find the "AI Generate" panel (camera icon)
- Click "Generate AI Image" button
- Click Auto from Post to generate a prompt (or write your own)
- Review the prompt and click Generate Images
- Wait 30-60 seconds for AI generation
- Review the 3 generated images and click Use This Image on your favorite
- Done! Featured image is automatically set
- Create or edit a post in the Classic Editor
- Click Set featured image button
- Click the AI Generate tab in the modal
- Click Auto from Post to generate a prompt (or write your own)
- Review the prompt and click Generate Images
- Wait 30-60 seconds for AI generation
- Review the 3 generated images and click Use This Image on your favorite
- Done! Featured image is automatically set
Note: The plugin automatically detects which editor you're using and provides the appropriate interface.
Configure different image styles per category:
- Technical Guides: "technical illustration, code elements, diagrams"
- AI Licensing: "abstract business concept, professional, legal aesthetic"
- Platform Updates: "modern SaaS UI, dashboard elements, product screenshots"
- Creator Stories: "human-centric, authentic, warm tones"
wp-ai-image-gen/
├── wp-ai-image-gen.php # Main plugin file
├── includes/
│ ├── class-settings.php # Settings page
│ ├── class-openrouter-client.php # OpenRouter API wrapper
│ ├── class-ajax-handler.php # AJAX endpoints
│ ├── class-modal-tab.php # Classic Editor integration
│ └── class-block-editor.php # Block Editor integration (NEW)
├── assets/
│ ├── js/
│ │ ├── modal-tab.js # Classic Editor UI
│ │ └── block-editor.js # Block Editor UI (NEW)
│ └── css/
│ ├── modal-tab.css # Classic Editor styles
│ └── block-editor.css # Block Editor styles (NEW)
├── README.md
└── BLOCK_EDITOR_INTEGRATION.md # Technical docs (NEW)
wpai_generate_prompt: Auto-generate prompt from postwpai_generate_image: Generate image from promptwpai_set_featured: Set generated image as featured
- Prompt Generation: ~$0.0001 per prompt (GPT-4o-mini)
- Image Generation: ~$0.01-0.04 per image depending on model:
- Google Gemini 2.5 Flash Image: ~$0.01 per image
- Black Forest Labs Flux 1.1 Pro: ~$0.04 per image
- Other models: See https://openrouter.ai/models
- Total per request: ~$0.03-0.12 (generates 3 images per request)
- Models: Verified working models via OpenRouter (Feb 2025):
google/gemini-2.5-flash-image- Nano Banana GA (default, recommended)google/gemini-3-pro-image-preview- Nano Banana Pro
- Aspect Ratios: Configurable per-generation (Gemini models only):
- 1:1 Square (1024×1024)
- 16:9 Widescreen (1344×768)
- 9:16 Portrait (768×1344)
- 4:3, 3:4, 3:2, 2:3, 5:4, 4:5, 21:9 also supported
- Format: PNG
- File naming:
{post-title} - AI Generated {index}.png
- Verify you're using the Block Editor (not Classic Editor)
- Check the Document tab in the right sidebar (not Block tab)
- Scroll down to find the "AI Generate" panel with camera icon
- Ensure plugin is activated and API key is configured
- Verify you're using the Classic Editor
- Click "Set featured image" to open media modal
- Look for "AI Generate" tab at the top
- If missing, check browser console for JavaScript errors
Go to Settings → AI Image Generator and add your OpenRouter API key.
Make sure you have permission to edit the post.
Image generation takes 30-60 seconds. If it times out:
- Check your internet connection
- Verify your OpenRouter API key is valid
- Check OpenRouter status: https://status.openrouter.ai/
- Try reducing number of images in settings
- Check WordPress media library permissions
- Verify
/wp-content/uploads/is writable - Check PHP upload limits (
upload_max_filesize,post_max_size)
- FIX: Removed non-working OpenRouter models causing 404 errors
- FIX: Updated model list to only verified working models (Gemini 2.5 Flash Image, Gemini 3 Pro)
- REMOVED: GPT-5 Image, Flux 2 models (don't support OpenRouter's modalities parameter)
- IMPROVED: Updated fallback model list in settings
- NEW: Block Editor (Gutenberg) support with sidebar panel
- NEW: Multiple AI model support via OpenRouter
- NEW: Generate 3 images per request, choose your favorite
- CHANGED: Migrated from OpenAI to OpenRouter API
- IMPROVED: Better error handling and loading states
- IMPROVED: Enhanced UI with React components for Block Editor
- Initial release
- Classic Editor modal tab integration
- Auto prompt generation
- Brand guidelines system
- Category presets
- Media library upload
- Featured image setting
- WordPress: 6.2 or higher (6.5+ recommended for best Block Editor support)
- PHP: 7.4 or higher
- OpenRouter API Key: Required
- Block Editor: Enabled (default in WordPress 5.0+) OR Classic Editor plugin installed
GPL-3.0-or-later
For issues or questions:
- GitHub: https://github.com/tymrtn/wp-ai-image-gen
- Email: [email protected]
Built for Copyright.sh by Tyler Martin