0) { // Conventional WordPress classes (wp-image-ID, size-*) so image filters / plugins can identify the attachment. $img = (string) wp_get_attachment_image($zx_id, $size, false, ['class' => 'zx-image__img size-' . $size . ' wp-image-' . $zx_id, 'alt' => $alt, 'loading' => 'lazy']); } // Fallback: the size URL stored by the media picker, then the original URL. $src = \Zadex\Frontend\Media::fallback_url($image, $size); if ($img === '' && $src !== '') { $img = '' . esc_attr($alt) . ''; } if ($img === '') { return; // Nothing to show. } // Link. $link_to = (string) ($settings['link_to'] ?? 'none'); $href = ''; $target = ''; $rel = []; $lightbox = false; if ($link_to === 'file') { $href = $zx_id > 0 ? (string) wp_get_attachment_url($zx_id) : ''; if ($href === '') { $href = $url; } $lightbox = !empty($settings['lightbox']); } elseif ($link_to === 'custom') { $zx_link = is_array($settings['link'] ?? null) ? $settings['link'] : []; $href = isset($zx_link['url']) && is_string($zx_link['url']) ? $zx_link['url'] : ''; $target = ($zx_link['target'] ?? '') === '_blank' ? '_blank' : ''; if (!empty($zx_link['nofollow'])) { $rel[] = 'nofollow'; } if ($target === '_blank') { $rel[] = 'noopener'; } } if ($href !== '') { $wrap = '' . $img . ''; } else { $wrap = '' . $img . ''; } // Caption. $caption = ''; $source = (string) ($settings['caption_source'] ?? 'none'); if ($source === 'attachment' && $zx_id > 0) { $caption = (string) wp_get_attachment_caption($zx_id); } elseif ($source === 'custom') { $caption = (string) ($settings['caption'] ?? ''); } $zx_tag = $caption !== '' ? 'figure' : 'div'; $zx_html = '<' . $zx_tag . ' ' . $attrs . '>' . $wrap . ($caption !== '' ? '
' . esc_html($caption) . '
' : '') . ''; echo wp_kses($zx_html, \Zadex\Frontend\Kses::allowed_html()) . "\n";