tempalte fix

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-01 11:15:10 +00:00
parent a38626ba67
commit 1eb25d1c47
2 changed files with 64 additions and 29 deletions

View File

@@ -41,8 +41,33 @@ if (!defined('ABSPATH')) {
<?php
// Get image for this section (position = section index + 1)
$section_position = $index + 1;
$has_image = isset($in_article_images[$section_position]);
$img_data = $has_image ? $in_article_images[$section_position] : null;
// Try multiple sources for in-article images
$img_data = null;
$img_url = null;
$img_prompt = '';
// Source 1: From $in_article_images array
if (isset($in_article_images[$section_position])) {
$img_data = $in_article_images[$section_position];
if (isset($img_data['attachment_id'])) {
$img_url = wp_get_attachment_image_url($img_data['attachment_id'], 'large');
$img_prompt = isset($img_data['prompt']) ? $img_data['prompt'] : '';
} elseif (isset($img_data['url'])) {
$img_url = $img_data['url'];
$img_prompt = isset($img_data['prompt']) ? $img_data['prompt'] : '';
}
}
// Source 2: Check gallery images meta
if (!$img_url) {
$gallery = get_post_meta(get_the_ID(), '_igny8_gallery_images', true);
if ($gallery && is_array($gallery) && isset($gallery[$index])) {
$img_url = wp_get_attachment_image_url($gallery[$index], 'large');
}
}
$has_image = !empty($img_url);
?>
<div class="igny8-section-content<?php echo $has_image ? ' igny8-has-image' : ''; ?>">
@@ -52,13 +77,11 @@ if (!defined('ABSPATH')) {
</div>
</div>
<?php if ($has_image && isset($img_data['attachment_id'])):
$img_id = $img_data['attachment_id'];
$img_url = wp_get_attachment_image_url($img_id, 'large');
$img_alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
$img_prompt = isset($img_data['prompt']) ? $img_data['prompt'] : '';
if ($img_url):
<?php if ($has_image):
$img_alt = '';
if (isset($img_data['attachment_id'])) {
$img_alt = get_post_meta($img_data['attachment_id'], '_wp_attachment_image_alt', true);
}
?>
<div class="igny8-section-image">
<figure class="igny8-image-figure">
@@ -74,7 +97,7 @@ if (!defined('ABSPATH')) {
<?php endif; ?>
</figure>
</div>
<?php endif; endif; ?>
<?php endif; ?>
</div>
</div>