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

@@ -123,6 +123,19 @@ class PRAutoBlogger {
update_option( 'prautoblogger_migrated_gemini_flash_lite', '1' );
}
// One-time migration: replace 90s infomercial style suffix with premium
// science editorial style. The old pastiche rendered poorly on Gemini/GPT-5
// Image models. Only overwrite if the stored value IS the old default — if
// the user customized it, respect their choice.
if ( ! get_option( 'prautoblogger_migrated_style_suffix_v2' ) ) {
$old_infomercial = 'Style: a screengrab from a 1995 late-night cable TV infomercial';
$current = get_option( 'prautoblogger_image_style_suffix', '' );
if ( '' === $current || false !== strpos( $current, $old_infomercial ) ) {
update_option( 'prautoblogger_image_style_suffix', PRAUTOBLOGGER_DEFAULT_IMAGE_STYLE_SUFFIX );
}
update_option( 'prautoblogger_migrated_style_suffix_v2', '1' );
}
// One-time migration: re-wrap existing encrypted values with "enc:" prefix.
if ( ! get_option( 'prautoblogger_migrated_enc_prefix' ) ) {
$enc_options = [ 'prautoblogger_openrouter_api_key', 'prautoblogger_ga4_credentials_json' ];