=== AI Featured image ===
Contributors: amr267, freemius
Donate link: https://buymeacoffee.com/unclegold
Tags: image generator, featured image, auto featured image, openai, gemini
Requires at least: 5.8
Tested up to: 7.0
Stable tag: 1.8.5
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

One-click AI featured images using OpenAI, Stability AI, or Grok. Pro adds Gemini, upscaling, background removal & unlimited bulk.

== Description ==

**AI Featured Image Generator** creates AI-powered featured images right from the WordPress editor. Click "Generate Featured Image" on any post and the plugin builds a unique image from your post title, chosen style, and optional custom prompt — using OpenAI, Stability AI, or Grok/xAI on the free plan, or Google Gemini on Pro.

Every image gets alt text automatically and an SEO-friendly filename based on your post title. Generate one at a time in the editor, in bulk, straight from the Posts list, or inline in your content with the AI Image Generator block. Everything is managed from one settings hub.

= Video Walkthrough =

https://youtu.be/kqdq8qwrdXY

= Free Features =

* **3 free AI providers**: OpenAI, Stability AI, and Grok/xAI (Google Gemini available on Pro)
* **OpenAI models**: GPT Image 2 (newest, default) — excels at text rendering in multiple languages, visual reasoning, multi-object scenes, transparent backgrounds, mask-based editing, and up to 4K output — plus GPT Image 1.5, GPT Image 1, and GPT Image 1 Mini (budget-friendly)
* **Stability AI**: Stable Image Core with 16 native style presets (Photographic, Cinematic, Anime, Digital Art, Comic Book, Fantasy Art, and more)
* **Grok/xAI**: Grok Imagine Image — fast and affordable at $0.02 per image
* **13 style presets**: Common (None, Realistic, Artistic, Cartoon, Minimalist) and Creative (Sketch, Watercolor, 3D Render, Pixel Art, Cyberpunk, Fantasy, Anime, Technicolor)
* **Custom prompts** — plus one-click **Generate Prompt from Content**, which crafts an AI-optimized prompt from your post title and body (OpenAI and Grok free; Gemini on Pro)
* **7 image sizes with GPT Image 2**: square, portrait, landscape, widescreen 16:9, vertical 9:16, ultra-wide 3:1, and tall banner 1:3 (older OpenAI models support the first three)
* **3 aspect ratios for Stability AI and Grok**: 1:1, 16:9, and 9:16
* **Output control (OpenAI)**: WebP/PNG/JPEG format, compression slider (1–100), and Low/Medium/High generation quality
* **Text control**: allow or block text, captions, and words in generated images
* **Auto alt text**: from the post title, the prompt, or a custom template with `{title}`, `{prompt}`, `{style}`, and `{site_name}` placeholders — with an option to preserve manual edits on regeneration
* **Bulk Generate**: up to 5 posts per batch, 50 images lifetime on the free plan
* **Generate from Post List**: an "AI Featured Image" column on the Posts/Pages list with a one-click Generate/Regenerate link — no need to open the editor, and it doesn't count against the free bulk limit
* **Inline images**: the AI Image Generator block adds AI images anywhere in your Gutenberg content, with its own settings tab
* **Multisite compatible**

= Pro Features 🚀 =

* **Google Gemini**: Nano Banana (Gemini 2.5 Flash), Nano Banana 2 Preview (Gemini 3.1 Flash), and Nano Banana Pro (Gemini 3 Pro) — up to 4K resolution and 10 aspect ratios
* **Image upscaling (Stability AI)**: Conservative (faithful 4x), Creative (AI-enhanced 4K), or Fast (quick 4x), right from the post editor
* **Background removal (Stability AI)**: one click isolates the subject and saves a transparent PNG as your featured image
* **Advanced Stability AI models**: Stable Image Ultra, SD 3.5 Large / Large Turbo / Medium / Flash, SD 3 Large / Large Turbo / Medium, and SDXL 1.0
* **Negative prompts (Stability AI)**: exclude unwanted elements, e.g. "blurry, watermark, text, low quality"
* **Grok Imagine Image Pro**: higher quality at $0.07 per image, plus 2K resolution
* **More aspect ratios**: 9 for Stability AI, 9 for Grok, 10 for Gemini
* **More output formats**: PNG/JPEG/WebP for Stability AI, and automatic WebP conversion for Gemini and Grok images
* **Unlimited Bulk Generate**: hundreds of posts at once with filters for post type, status, date range, and thumbnail status, plus real-time progress
* **Custom post types**: enable generation for any public post type
* **Custom styles**: create named styles with your own prompt descriptions, available in every style dropdown

Want to unlock Google Gemini AI, image upscaling, background removal, unlimited bulk generation and more? <a href="https://checkout.freemius.com/plugin/22299/plan/37317/licenses/1/">Upgrade to Pro here</a>.

= Requirements =

* WordPress 5.8 or higher
* PHP 7.4 or higher
* An API key for at least one provider:
  * [OpenAI](https://platform.openai.com/api-keys) (free plan)
  * [Stability AI](https://platform.stability.ai/account/keys) (free plan)
  * [Grok/xAI](https://console.x.ai/) (free plan)
  * [Google Gemini](https://aistudio.google.com/app/apikey) (Pro only)

== External Services ==

This plugin connects to your chosen AI provider's API to generate images. For every provider:

* Your post title and content (or your custom prompt, and for Stability AI any negative prompt) are sent to the provider's API when you generate an image
* Your API key for that provider authenticates each request
* Requests are only sent when you trigger generation — from the post editor, the Posts list, Bulk Generate, or the AI Image Generator block
* "Generate Prompt from Content" sends your post title and body to the provider's text API: gpt-4o-mini (OpenAI), grok-3-mini (Grok), or Gemini 2.5 Flash (Gemini, Pro)

**OpenAI (Free & Pro)** — image generation and prompt generation.
[Terms of Service](https://openai.com/policies/terms-of-use) | [Privacy Policy](https://openai.com/policies/privacy-policy) | [API Documentation](https://platform.openai.com/docs)

**Stability AI (Free & Pro)** — image generation; for Pro users, upscaling and background removal also send your existing featured image file to Stability AI for processing.
[Terms of Service](https://stability.ai/terms-of-service) | [Privacy Policy](https://stability.ai/privacy-policy) | [API Documentation](https://platform.stability.ai/docs/api-reference)

**Grok / xAI (Free & Pro)** — image generation and prompt generation.
[Terms of Service](https://x.ai/legal/terms-of-service) | [Privacy Policy](https://x.ai/legal/privacy-policy) | [API Documentation](https://docs.x.ai/docs)

**Google Gemini (Pro only)** — image generation and prompt generation.
[Terms of Service](https://ai.google.dev/gemini-api/terms) | [Privacy Policy](https://policies.google.com/privacy) | [API Documentation](https://ai.google.dev/gemini-api/docs)

**Data usage:** generated images are stored in your WordPress media library. No personal data is stored by the providers beyond what's necessary for API processing. You are responsible for ensuring your content complies with the selected provider's usage policies.

== Installation ==

1. Upload the `ai-featured-image-generator` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to AI Image in the admin menu to configure your API key and other settings
4. The AI Image Generator block is available in the Gutenberg block inserter for adding inline images

== Frequently Asked Questions ==

= Do I need an API key? =

Yes — for at least one provider. All free-plan providers have free tiers or pay-as-you-go pricing: [OpenAI](https://platform.openai.com/api-keys), [Stability AI](https://platform.stability.ai/account/keys), [Grok/xAI](https://console.x.ai/), or [Google Gemini](https://aistudio.google.com/app/apikey) (Pro only).

= How much does it cost? =

The plugin is free; you pay your provider per image:

* **OpenAI**: varies by model — GPT Image 1 Mini is the most cost-effective; see [OpenAI pricing](https://openai.com/api/pricing/)
* **Stability AI**: Stable Image Core is roughly ~$0.003/image; other models vary; see [Stability AI pricing](https://platform.stability.ai/pricing)
* **Grok/xAI**: $0.02/image (Grok Imagine Image) or $0.07/image (Pro model)
* **Google Gemini (Pro)**: Gemini 2.5 Flash uses 1290 tokens per image; Gemini 3.1 Flash and 3 Pro vary by resolution

= Can I switch between providers? =

Yes. Select your provider and enter its API key in the plugin settings — the page shows only the options relevant to your selection. Free users can switch between OpenAI, Stability AI, and Grok/xAI; Pro adds Google Gemini.

= Is there a limit to how many images I can generate? =

Only your API plan's quota with your chosen provider. The plugin generates one image per request.

= What AI models are available? =

**OpenAI (Free & Pro):** GPT Image 2 (newest, most accurate — best text rendering and visual reasoning), GPT Image 1.5 (strong quality, cheaper and faster than GPT Image 1), GPT Image 1 (standard), and GPT Image 1 Mini (most cost-effective).

**Stability AI:** Stable Image Core (free — fast, high quality, best value). Pro adds Stable Image Ultra (best quality), SD 3.5 Large / Large Turbo / Medium / Flash, SD 3 Large / Large Turbo / Medium, and SDXL 1.0 (legacy).

**Grok / xAI:** Grok Imagine Image (free, $0.02/image) and Grok Imagine Image Pro (Pro, $0.07/image).

**Google Gemini (Pro only):** Gemini 2.5 Flash Image (fixed resolutions), Gemini 3.1 Flash Image Preview (1K/2K/4K), and Gemini 3 Pro Image Preview (best quality, 1K/2K/4K). All support 10 aspect ratios.

= What styles are available? =

13 built-in styles that work with all providers: None, Realistic, Artistic, Cartoon, Minimalist, Sketch, Watercolor, 3D Render, Pixel Art, Cyberpunk, Fantasy, Anime, and Technicolor.

With Stability AI you also get a **Stability Presets** group of 16 native API-level presets: Photographic, Cinematic, Anime, Digital Art, Comic Book, Fantasy Art, 3D Model, Analog Film, Enhance, Isometric, Line Art, Low Poly, Neon Punk, Origami, Pixel Art, and Tile Texture.

Pro users can also create unlimited custom styles (see below).

= Can I create my own custom styles? (Pro) =

Yes. Go to **AI Featured Image → Settings → Featured Images → Custom Styles**, click "Add Style", and enter a name plus a prompt description (e.g. "in a dreamy impressionist style"). Custom styles appear in all style dropdowns and work exactly like built-in styles.

= What image sizes and aspect ratios are supported? =

* **OpenAI**: 7 sizes with GPT Image 2 — 1024x1024 (1:1), 1024x1536 (portrait), 1536x1024 (landscape), 1792x1024 (16:9), 1024x1792 (9:16), 1920x640 (3:1), and 640x1920 (1:3). Older OpenAI models support the first three
* **Stability AI**: 1:1, 16:9, and 9:16 free; Pro unlocks all 9 (adds 21:9, 2:3, 3:2, 4:5, 5:4, 9:21)
* **Grok**: 1:1, 16:9, and 9:16 free; Pro unlocks all 9 (adds 4:3, 3:4, 3:2, 2:3, 2:1, 1:2)
* **Gemini (Pro)**: 10 ratios (1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9) — fixed resolutions on Gemini 2.5 Flash, 1K/2K/4K on Gemini 3.1 Flash and 3 Pro

= Can I upscale my featured image? (Pro) =

Yes, with a Stability AI API key. Once a featured image is set, a "Stability AI Tools" panel appears in the post editor with three modes: **Conservative** (faithful 4x), **Creative** (AI-enhanced 4K), and **Fast** (quick 4x). Conservative and Creative process asynchronously and may take up to ~3 minutes; the result automatically becomes your new featured image.

= Can I remove the background from my featured image? (Pro) =

Yes, from the same "Stability AI Tools" panel. Click "Remove Background" and Stability AI isolates the subject and saves a transparent PNG as your featured image — great for product shots and portraits.

= What is a negative prompt? (Stability AI, Pro) =

Text that tells Stability AI what **not** to include, e.g. "blurry, watermark, text, low quality". Set defaults in **Settings → Featured Images** (and the Inline Images tab). Negative prompts have no effect with OpenAI, Gemini, or Grok.

= What output formats are supported? =

* **OpenAI**: WebP (recommended), PNG, or JPEG
* **Stability AI**: PNG free; Pro adds JPEG and WebP
* **Grok**: JPEG free; Pro adds WebP (converted after generation)
* **Gemini (Pro)**: PNG default, or WebP (converted after generation)

Because the Gemini and Grok APIs return PNG/JPEG, the plugin converts to WebP using your server's image library (ImageMagick or GD).

= Why was my image saved as PNG or JPEG instead of WebP? =

WebP conversion for Gemini and Grok needs a WebP-capable image library on your server (GD with WebP, or ImageMagick with the WebP delegate). If it's missing, the plugin safely falls back to the provider's native format and shows a notice with the reason — generation never fails. Ask your host to enable WebP if needed. OpenAI WebP is unaffected because the API returns it directly.

= How does quality control work? =

* **OpenAI**: Output Compression slider (1–100, default 90) plus a Low/Medium/High generation quality tier
* **Stability AI**: quality is inherent to the model you choose
* **Grok**: 1K resolution free; Pro can choose 2K
* **Gemini (Pro)**: fixed resolutions on 2.5 Flash; 1K/2K/4K on 3.1 Flash and 3 Pro
* **Inline images (all providers)**: Automatic Quality Optimization picks quality and resolution based on the image's display size in your content

= Can I generate images inside the Gutenberg editor? =

Yes. Add the "AI Image Generator" block from the Media category, enter a prompt, and generate images anywhere in your content. The block supports the same providers, styles, and aspect ratios as featured images; configure defaults in the Inline Images settings tab.

= How does auto alt text work? =

Every AI image (featured, inline, or bulk) automatically gets alt text in the media library. Configure it under **Settings → General → Alt Text**: choose the post title (default), the generation prompt, or a custom template with `{title}`, `{prompt}`, `{style}`, and `{site_name}` placeholders — e.g. `{title} - {style} style - {site_name}`. By default, manually edited alt text is preserved on regeneration; enable "Overwrite on Regeneration" to always refresh it.

= How does "Generate Prompt from Content" work? =

Click **"Generate Prompt from Content"** in the post editor and AI writes an image prompt from your post title and body. It's saved to the post and pre-filled in the Custom Prompt field so you can review or edit before generating. The same option exists in Bulk Generate, creating a unique prompt per post.

Text model per provider: gpt-4o-mini (OpenAI), grok-3-mini (Grok), Gemini 2.5 Flash (Gemini, Pro). Stability AI has no text API, so the button shows a notice when it's the active provider.

= Does it work with custom post types? (Pro) =

Yes. Go to **AI Featured Image → Enabled Post Types**, check the post types you want, and save. The generator panel then appears in the editor for those post types. Free users are limited to Posts and Pages.

== Screenshots ==

1. General settings: API configuration, provider selection, and post type availability
2. Post editor meta box: custom prompt, style picker, and Generate Featured Image button
3. Generated image preview: AI-generated featured image set directly from the post editor
4. AI Provider selector: choose between OpenAI, Stability AI, Grok/xAI, or Google Gemini (Pro)
5. AI Model selector: pick from GPT Image 2, GPT Image 1.5, GPT Image 1, or GPT Image 1 Mini
6. Featured Images settings: default aspect ratio, style, text options, and output format
7. Aspect ratio options: choose Square, Portrait, or Landscape for generated images
8. Style presets: 13 styles organized into Common and Creative groups
9. Output format selector: WebP (recommended), PNG, or JPEG
10. Bulk Generate tab: filter posts and generate featured images in batches
11. Bulk Generate: select posts and start batch generation
12. Bulk Generate progress: real-time progress bar with per-post status
13. Bulk Generate summary: completed results with success, skipped, and failed counts

== Changelog ==

= 1.8.5 =
* Bug fixes

= 1.8.3 =
* **WebP for Gemini & Grok (Pro)**: featured and inline images from Gemini and Grok are now converted to lightweight WebP after generation (Imagick or GD). WebP becomes the recommended default for Pro; free users keep the native format
* **Consistent output formats**: Gemini and Grok get their own Output Format selector on the Featured and Inline Images tabs
* **Safe fallback**: if a server can't produce WebP, generation never fails — the image is saved in the provider's native format and you're notified with the reason

= 1.8.2 =
* **Inline Images now free**: the AI Image Generator block and its settings tab are available to all users (OpenAI, Stability AI, Grok; Gemini remains Pro)
* **Plugin renamed** to "AI Featured Image Generator with Output Control"
* **Compatibility notice** when the official WordPress "AI" plugin is active with image generation enabled

= 1.8.1 =
* **Generate from Post List**: a new "AI Featured Image" column on the Posts/Pages list with a one-click Generate/Regenerate link — no need to open the editor
* Auto-builds the prompt from post title and content, respects all global settings, confirms before overwriting an existing image, and doesn't count against the free bulk limit
* Per-post 5-second rate limit prevents accidental double-clicks

= 1.8.0 =
* **New model (OpenAI)**: GPT Image 2, now the default for new installs — text rendering, visual reasoning, multi-object scenes, up to 4K, transparent backgrounds, quality tiers, moderation control, and 4 additional sizes
* **New provider: Stability AI** (free): Stable Image Core with 16 native style presets; Pro adds Ultra, SD 3.5/SD 3 variants, SDXL 1.0, negative prompts, output formats, and 9 aspect ratios
* **New provider: Grok/xAI** (free): Grok Imagine Image at $0.02/image; Pro adds the Pro model, 9 aspect ratios, and 2K resolution
* **New Pro tools**: image upscaling (Conservative/Creative/Fast) and one-click background removal via Stability AI
* Automatic Quality Optimization for inline images, Stability key validation with credit balance, improved API error messages, and assorted fixes

= 1.5.4 =
* Auto Alt Text for all AI-generated images with title/prompt/custom-template sources; free bulk limit raised from 20 to 50 images

= 1.5.0 =
* Custom Styles (Pro), Bulk Generate for free users (5 posts/batch, 50 lifetime), unified settings hub with AJAX tabs, API key Test Connection, new models (ChatGPT Image Latest, Gemini 3.1 Flash Preview), and a full admin UI overhaul

= 1.4.x =
* Inline image generation in Gutenberg with a dedicated Inline Images settings tab, PNG output fixes, and WordPress 6.9.1 compatibility

= 1.3.x =
* Google Gemini provider (Pro), custom post types (Pro), gpt-image-1.5 model, redesigned card-based settings UI, top-level admin menu, and Freemius integration

= 1.2.x =
* Output format selection (WebP/PNG/JPEG), image quality control, model selection (GPT Image 1 vs Mini), and Classic Editor compatibility fixes

= 1.0.0 – 1.1.0 =
* Initial releases: core featured-image generation, style presets, Pages support, and UI improvements

== Upgrade Notice ==

= 1.8.1 =
New: Generate AI featured images directly from the Posts/Pages admin list! A new "AI Featured Image" column shows the current thumbnail and a one-click Generate Image / Regenerate Image link, with no need to open each post. Auto-builds the prompt from title + content, respects all your provider settings, and does not count against the free bulk-generation limit.

= 1.8.0 =
Major update! New OpenAI GPT Image 2 model (now default) with text rendering, visual reasoning, 4K output, 7 aspect ratios, transparent backgrounds, generation quality tiers, and moderation control. Two new free providers: Stability AI (16 style presets) and Grok/xAI ($0.02/image). Pro users gain image upscaling, background removal, negative prompts, advanced Stability AI models, Grok Pro, extended aspect ratios, and automatic quality optimization for inline images.
