temaplte fixes in app and in plugin

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-10 06:17:38 +00:00
parent 975eab46cf
commit 9e785f141c
11 changed files with 311 additions and 173 deletions

View File

@@ -854,6 +854,7 @@ function igny8_set_featured_image($post_id, $image_data) {
*/
function igny8_set_image_gallery($post_id, $gallery_images) {
$attachment_ids = array();
$imported_images = array(); // For _igny8_imported_images meta with full metadata
// Limit to 5 images
$gallery_images = array_slice($gallery_images, 0, 5);
@@ -875,6 +876,19 @@ function igny8_set_image_gallery($post_id, $gallery_images) {
if ($attachment_id) {
$attachment_ids[] = $attachment_id;
// Build complete image metadata for template
$position = is_array($image_data) ? ($image_data['position'] ?? 0) : 0;
$caption = is_array($image_data) ? ($image_data['caption'] ?? '') : ''; // Use caption instead of prompt
$is_featured = is_array($image_data) ? ($image_data['is_featured'] ?? false) : false;
$imported_images[] = array(
'position' => intval($position),
'attachment_id' => $attachment_id,
'url' => wp_get_attachment_url($attachment_id),
'prompt' => $caption, // Store caption in prompt field for template compatibility
'is_featured' => $is_featured
);
}
}
@@ -887,6 +901,14 @@ function igny8_set_image_gallery($post_id, $gallery_images) {
update_post_meta($post_id, '_gallery_images', $attachment_ids); // Generic
}
// Store complete image metadata for IGNY8 template
if (!empty($imported_images)) {
update_post_meta($post_id, '_igny8_imported_images', $imported_images);
$log_prefix = "[" . get_option('igny8_site_id', 'N/A') . "-" . parse_url(site_url(), PHP_URL_HOST) . "]";
Igny8_Logger::info("{$log_prefix} ✅ Saved _igny8_imported_images meta with " . count($imported_images) . " images (positions: " . implode(', ', array_column($imported_images, 'position')) . ")");
}
return $attachment_ids;
}