* @todo add caching to this function * @todo create fm-overlay specific image sizes (?) */ public function get_overlay_image_sizes($attachment_id) { // Create an array of all the image sizes required $image_sizes = array('desktop_src' => $this->get_image_src($attachment_id, 'full'), 'tablet_src' => $this->get_image_src($attachment_id, 'large'), 'mobile_src' => $this->get_image_src($attachment_id, 'medium')); return $image_sizes; } /** * Namespace single or collection of Class(es) * * @param string/array $classes either a string or array of classes to be namespaced * @return string/array namespaced single class or array of namespace classes */ public function namespace_classes($classes) { if (is_array($classes)) { $formatted_classes = array(); foreach ($classes as $class) { $formatted_classes[] = 'fm-overlay-' . $class; } $formatted_classes = array_unique($formatted_classes); } else { $formatted_classes = 'fm-overlay-' . $classes; } return $formatted_classes; } } Fm_Overlays_Helpers::instance();
$fm_overlay_classes = Fm_Overlays_Helpers::instance()->get_overlay_classes($overlay); $targeted_conditions = Fm_Overlays::instance()->targeted_conditions; ?> <div id="fm-overlay" class="<?php echo esc_attr($fm_overlay_classes); ?> " data-cookiename="<?php echo esc_attr(Fm_Overlays::instance()->get_overlay_cookie_name($overlay->ID)); ?> " data-condition="<?php echo esc_attr(implode(' ', Fm_Overlays_Helpers::instance()->namespace_classes($targeted_conditions))); ?> "> <div class="fm-overlay-wrapper"> <!-- @TODO: classes can be `.icon`, `.text`, or `.icon.text` --> <button aria-label="Close Overlay" class="fm-overlay-close icon"> <span class="close-text"><?php esc_html_e('Close', 'fm-overlays'); ?> </span> <svg> <g transform="scale(0.02 0.02)"> <path d="M1014.662 822.66c-0.004-0.004-0.008-0.008-0.012-0.010l-310.644-310.65 310.644-310.65c0.004-0.004 0.008-0.006 0.012-0.010 3.344-3.346 5.762-7.254 7.312-11.416 4.246-11.376 1.824-24.682-7.324-33.83l-146.746-146.746c-9.148-9.146-22.45-11.566-33.828-7.32-4.16 1.55-8.070 3.968-11.418 7.31 0 0.004-0.004 0.006-0.008 0.010l-310.648 310.652-310.648-310.65c-0.004-0.004-0.006-0.006-0.010-0.010-3.346-3.342-7.254-5.76-11.414-7.31-11.38-4.248-24.682-1.826-33.83 7.32l-146.748 146.748c-9.148 9.148-11.568 22.452-7.322 33.828 1.552 4.16 3.97 8.072 7.312 11.416 0.004 0.002 0.006 0.006 0.010 0.010l310.65 310.648-310.65 310.652c-0.002 0.004-0.006 0.006-0.008 0.010-3.342 3.346-5.76 7.254-7.314 11.414-4.248 11.376-1.826 24.682 7.322 33.83l146.748 146.746c9.15 9.148 22.452 11.568 33.83 7.322 4.16-1.552 8.070-3.97 11.416-7.312 0.002-0.004 0.006-0.006 0.010-0.010l310.648-310.65 310.648 310.65c0.004 0.002 0.008 0.006 0.012 0.008 3.348 3.344 7.254 5.762 11.414 7.314 11.378 4.246 24.684 1.826 33.828-7.322l146.746-146.748c9.148-9.148 11.57-22.454 7.324-33.83-1.552-4.16-3.97-8.068-7.314-11.414z"></path> </g> </svg> </button>
<?php /** * FM Overlays Image Template * * implements the srcset attribute in the <img> tag */ $image_sizes = Fm_Overlays_Helpers::instance()->get_overlay_image_sizes($overlay->overlay_content['image_id']); $classes = 'entry-thumbnail fm-image'; $alt_text = the_title_attribute(array('echo' => false)); $id = 'attachment_' . $overlay->overlay_content['image_id']; ?> <?php if (!empty($image_sizes)) { ?> <div <?php if (!empty($id)) { ?> id="<?php echo esc_attr($id); ?> "<?php } ?> <?php if (!empty($classes)) { ?> class="<?php echo esc_attr($classes); ?>