fix: attach images immediately + upgrade image prompts to v2

Two fixes:

1. Image attachment: moved set_post_thumbnail() and Image B post meta
   into generate_and_attach_images() so they persist immediately after
   each image generates. Previously the caller set them after both images
   completed — if the process timed out (common with GPT-5 Image at
   ~30s/image), the featured image was never attached and Image B was
   never attempted.

2. Image prompts: replaced FLUX.1-optimized rewriter system prompt and
   90s infomercial style suffix with prompts optimized for Gemini Flash
   Image and GPT-5 Image. New style: premium scientific lifestyle
   photography with golds/teals color grading. Includes one-time migration
   to update stored style suffix.

Also logs when Image B is skipped due to missing source data (previously
silent), helping diagnose why some posts only get one image.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
peptiderepo
2026-04-18 12:17:05 +07:00
parent dd406c5ba6
commit 1a2af595c6
6 changed files with 63 additions and 41 deletions

View File

@@ -28,17 +28,22 @@ class PRAutoBlogger_Image_Prompt_Builder {
* code review, not an admin-panel click.
*/
private const REWRITER_SYSTEM_PROMPT = <<<'PROMPT'
You are an image-prompt specialist for FLUX.1, a text-to-image model.
You are an image-prompt specialist for premium AI image models (Gemini Flash Image, GPT-5 Image).
Given an article title and summary, output ONE short paragraph (2-4 sentences, under 60 words) describing a concrete visual scene that would make a compelling featured image for the article.
Given an article title and summary about peptides, supplements, or biohacking, write ONE vivid scene description (2-3 sentences, under 80 words) for a compelling featured image. Emphasize:
- OBJECTS and MATERIALS: lab glassware, peptide vials, molecular structures, syringes, supplement bottles, biometric devices, microscopes, fitness equipment, test tubes
- LIGHTING and DEPTH: bright directional studio lighting, selective focus, rich warm/cool color contrasts
- COMPOSITION: dynamic framing with clear focal point, professional product photography perspective, sense of scale and precision
- MOOD: scientific credibility paired with aspirational wellness — premium feel, approachable, engaging
Rules:
- Describe OBJECTS, SETTING, LIGHTING, COMPOSITION, and MOOD — not abstract concepts.
- Never include text, words, labels, logos, or watermarks in the scene.
- Never describe people's faces in detail (FLUX.1 struggles with faces). Use silhouettes, hands, or over-the-shoulder framings instead.
- Focus on the article's core SUBJECT as a physical thing: lab equipment, supplements, syringes, molecules, gym settings, packaging, etc.
- Do NOT include any style direction — that is appended separately.
- Output ONLY the scene description. No preamble, no explanation, no quotes.
Avoid:
- Abstract concepts; show concrete objects only
- Text, logos, watermarks, or readable labels
- Detailed human faces (use hands, torso, silhouettes, or exclude people)
- Multiple competing visual elements; keep the subject dominant
- Generic stock-photo composition
Output ONLY the scene description — no preamble, explanation, or quotes. Do NOT include any style direction; that is appended separately.
PROMPT;
/**