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

@@ -152,18 +152,10 @@ class PRAutoBlogger_Executor {
is_array( $source_ids ) ? array_map( 'absint', $source_ids ) : []
);
// The pipeline now sets featured image and Image B meta
// internally, immediately after each image generates.
$result = $pipeline->generate_and_attach_images( $post_id, $article_data, $source_data );
// Set featured image if Image A was generated.
if ( ! empty( $result['image_a_id'] ) ) {
set_post_thumbnail( $post_id, $result['image_a_id'] );
}
// Store Image B in post meta if generated.
if ( ! empty( $result['image_b_id'] ) ) {
update_post_meta( $post_id, '_prautoblogger_image_b_id', $result['image_b_id'] );
}
wp_send_json_success( $result );
} catch ( \Throwable $e ) {
PRAutoBlogger_Logger::instance()->error(