* [figure | icon] [content (title, desc, button)] * * * @param array $attrs Block attributes. * @param string $content Block content (unused). * @param WP_Block $block Parsed block. * @param ModuleElements $elements Module elements helper. * * @return string */ public static function render_callback($attrs, $content, $block, $elements) { $advanced = $attrs['module']['advanced'] ?? []; $use_icon = ($advanced['useIcon']['desktop']['value'] ?? 'off') === 'on'; $use_badge = ($advanced['useBadge']['desktop']['value'] ?? 'off') === 'on'; $use_button = ($advanced['useButton']['desktop']['value'] ?? 'off') === 'on'; $overlay_on = ($advanced['overlayOnHover']['desktop']['value'] ?? 'on') === 'on'; $hover_anim = $advanced['imageHoverAnimation']['desktop']['value'] ?? 'none'; $use_light = ($advanced['useLightbox']['desktop']['value'] ?? 'off') === 'on'; // The D5 upload field stores the image as an object (`{ src, ... }`); // accept both that and a plain URL string. $photo_val = $attrs['photo']['innerContent']['desktop']['value'] ?? ''; $photo_src = is_array($photo_val) ? ($photo_val['src'] ?? '') : $photo_val; $photo_alt = $attrs['photo']['advanced']['alt']['desktop']['value'] ?? ''; // Badge. $badge_html = ''; if ($use_badge) { $badge_html = $elements->render(['attrName' => 'badge']); } // Figure (only when icon is OFF and an image is set). $figure_html = ''; if (!$use_icon && !empty($photo_src)) { $overlay_html = ''; if ($overlay_on) { $overlay_icon = $advanced['overlayIcon']['desktop']['value'] ?? ''; if (is_array($overlay_icon)) { $overlay_uni = $overlay_icon['unicode'] ?? ''; $overlay_type = $overlay_icon['type'] ?? 'divi'; $overlay_wt = $overlay_icon['weight'] ?? '400'; } else { $overlay_parts = explode('||', (string) $overlay_icon); $overlay_uni = $overlay_parts[0] ?? ''; $overlay_type = $overlay_parts[1] ?? 'divi'; $overlay_wt = $overlay_parts[2] ?? '400'; } if ('' !== $overlay_uni) { $overlay_font = 'fa' === $overlay_type ? 'FontAwesome' : 'ETmodules'; dtq_inject_fa_icons($overlay_uni . '||' . $overlay_type . '||' . $overlay_wt); $overlay_html = sprintf( '
', esc_attr($overlay_font), esc_attr($overlay_wt), dtq_resolve_icon_unicode($overlay_uni) ); } } $lightbox_class = $use_light ? ' dtq-lightbox' : ''; $figure_html = sprintf( '