includes/divi5/modules/`; it is NOT a module and * must not be registered in the dependency tree. * * Static class (not a trait) on purpose: modules already `use` several traits; * a shared trait sharing method names would cause PHP trait-collision fatals. * * @package DiviTorqueLite\Modules\SharedCarousel * @since 4.5.0 */ namespace DiviTorqueLite\Modules\SharedCarousel; if (!defined('ABSPATH')) { exit; } class CarouselEngine { /** * Parse the leading integer out of a value like "3" or "700ms". * * @param mixed $val Raw value. * @param int $fallback Fallback integer. * * @return int */ public static function to_int($val, $fallback) { if (null === $val || '' === $val) { return $fallback; } $n = (int) $val; // Divi saves lengths and durations with their unit ("0ms", "0px"), so // a zero has to be recognised with a unit too. Matching only a bare "0" // turned Autoplay Delay 0 into 2000ms and Gap Between Slides 0 into // 10px on the front end, while the builder (config.js) kept the 0. $is_zero = 1 === preg_match('/^\s*0+(?:\.0*)?\s*[a-z%]*\s*$/i', (string) $val); return ($n > 0 || $is_zero) ? $n : $fallback; } /** * Parse a leading signed integer ("-20px" is -20), mirroring config.js * num(). For values that may be negative, where to_int() would fall back. * * @param mixed $val Raw value. * @param int $fallback Fallback integer. * * @return int */ public static function to_signed_int($val, $fallback) { if (null === $val || '' === $val) { return $fallback; } return 1 === preg_match('/^\s*([+-]?\d+)/', (string) $val, $m) ? (int) $m[1] : $fallback; } /** * The carousel's transition effect, or 'slide' for anything unknown. * Mirrors carouselEffect() in config.js. * * @param array $advanced The module advanced attrs. * * @return string */ public static function effect($advanced) { $effect = $advanced['effect']['desktop']['value'] ?? 'slide'; return in_array($effect, ['slide', 'fade', 'coverflow', 'cards', 'flip', 'cube'], true) ? $effect : 'slide'; } /** * A setting's value on each device. An unset tablet value falls back to * desktop and an unset phone value to tablet, the chain Divi shows in the * builder. Mirrors atEachDevice() in config.js. * * @param array $advanced The module advanced attrs. * @param string $key Attribute name. * @param mixed $fallback Desktop default. * * @return array ['desktop' => mixed, 'tablet' => mixed, 'phone' => mixed] */ public static function at_each_device($advanced, $key, $fallback) { $at = function ($bp) use ($advanced, $key) { $raw = $advanced[$key][$bp]['value'] ?? null; return (null === $raw || '' === $raw) ? null : $raw; }; $desktop = $at('desktop') ?? $fallback; $tablet = $at('tablet') ?? $desktop; $phone = $at('phone') ?? $tablet; return ['desktop' => $desktop, 'tablet' => $tablet, 'phone' => $phone]; } /** * Whether the arrows and the dots show on each device. Continuous Scroll * has neither. The markup is rendered when any device shows them; the * styles hide them where they are off. Mirrors controlsAtEachDevice(). * * @param array $advanced The module advanced attrs. * * @return array ['nav' => bool[], 'pagi' => bool[]] keyed by device. */ public static function controls_at_each_device($advanced) { $continuous = self::is_continuous($advanced); $nav = self::at_each_device($advanced, 'useNav', 'on'); $pagi = self::at_each_device($advanced, 'usePagi', 'off'); $out = ['nav' => [], 'pagi' => []]; foreach (['desktop', 'tablet', 'phone'] as $device) { $out['nav'][$device] = !$continuous && 'off' !== $nav[$device]; $out['pagi'][$device] = !$continuous && 'on' === $pagi[$device]; } return $out; } /** * Does this carousel run Continuous Scroll? Needs autoplay and the plain * slide effect. Mirrors isContinuous() in config.js. * * @param array $advanced The module advanced attrs. * * @return bool */ public static function is_continuous($advanced) { return 'on' === ($advanced['isAutoplay']['desktop']['value'] ?? 'on') && 'continuous' === ($advanced['autoplayMode']['desktop']['value'] ?? 'step') && 'slide' === self::effect($advanced) && self::grid_rows($advanced) <= 1; } /** * Rows of slides (Swiper grid), 1 to 4. Only a horizontal, fixed-width * carousel with the slide effect can stack rows; anything else gets 1. * Mirrors gridRows() in config.js. * * @param array $advanced The module advanced attrs. * * @return int */ public static function grid_rows($advanced) { if ('slide' !== self::effect($advanced) || 'on' === ($advanced['isVertical']['desktop']['value'] ?? 'off') || 'on' === ($advanced['isVariableWidth']['desktop']['value'] ?? 'off') ) { return 1; } return min(4, max(1, self::to_int($advanced['gridRows']['desktop']['value'] ?? '1', 1))); } /** * The parent carousel's `module.advanced` attrs, for a slide's render. * Pinch to Zoom and Parallax Captions change the slide markup, so the * slide needs to know how its carousel is set. Defaults and presets are * folded in through Divi's own get_all_attrs(). * * @param object $block The slide's parsed block. * * @return array */ public static function parent_advanced($block) { $store = '\ET\Builder\FrontEnd\BlockParser\BlockParserStore'; if (!is_object($block) || empty($block->parsed_block['id']) || !class_exists($store) || !method_exists($store, 'get_parent')) { return []; } $parent = $store::get_parent($block->parsed_block['id'], $block->parsed_block['storeInstance'] ?? null); if (!$parent) { return []; } $utils = '\ET\Builder\Packages\ModuleUtils\ModuleUtils'; $attrs = (class_exists($utils) && method_exists($utils, 'get_all_attrs')) ? $utils::get_all_attrs($parent) : ($parent->attrs ?? []); $advanced = $attrs['module']['advanced'] ?? []; return is_array($advanced) ? $advanced : []; } /** * Slide markup options that come from the parent carousel. * * @param array $parent The parent's `module.advanced` attrs. * * @return array ['zoom' => bool, 'parallax' => int|null] Parallax is the caption offset in px, or null. */ public static function slide_options($parent) { $continuous = self::is_continuous($parent); $zoom = !$continuous && 'on' === ($parent['enableZoom']['desktop']['value'] ?? 'off'); $parallax = (!$continuous && 'on' === ($parent['parallaxCaptions']['desktop']['value'] ?? 'off')) ? max(0, self::to_int($parent['parallaxAmount']['desktop']['value'] ?? '60px', 60)) : null; return ['zoom' => $zoom, 'parallax' => $parallax]; } /** * Resolve a Divi icon value to its glyph char + font. * * @param mixed $icon Icon value (object or "unicode||type||weight"). * @param string $fallback Fallback glyph char. * * @return array ['char' => string, 'font' => string, 'weight' => string] */ public static function resolve_arrow($icon, $fallback) { $unicode = ''; $type = 'divi'; $weight = '400'; if (is_array($icon)) { $unicode = $icon['unicode'] ?? ''; $type = $icon['type'] ?? 'divi'; $weight = $icon['weight'] ?? '400'; } elseif (is_string($icon) && '' !== $icon) { $parts = explode('||', $icon); $unicode = $parts[0] ?? ''; $type = $parts[1] ?? 'divi'; $weight = $parts[2] ?? '400'; } // A layout migrated from Divi 4 carries the legacy `%%24%%` icon form, // which html_entity_decode leaves untouched, so the arrow renders as // literal text. Resolve it to a real glyph first. if ('' !== $unicode && function_exists('dtq_resolve_icon_unicode')) { $unicode = dtq_resolve_icon_unicode($unicode); } $char = '' !== $unicode ? html_entity_decode($unicode, ENT_QUOTES, 'UTF-8') : $fallback; return [ 'char' => $char, 'font' => 'fa' === $type ? 'FontAwesome' : 'ETmodules', 'weight' => $weight ?: '400', ]; } /** * Build the Swiper config array, mirroring the JS `buildSwiperConfig()`. * * @param array $advanced The `module.advanced` attrs array. * * @return array ['config' => array, 'show_nav' => bool, 'show_pagi' => bool] */ public static function build_swiper_config($advanced) { // On-demand: every front-end carousel render funnels through here, so // this is the single point that pulls in the Swiper library. Registered // (not enqueued) in Modules.php, so pages without a carousel never load // it. Guarded for non-WP/REST contexts. if (function_exists('wp_enqueue_script')) { wp_enqueue_style('divi-torque-lite-swiper'); wp_enqueue_script('divi-torque-lite-swiper'); } $val = function ($key, $fallback) use ($advanced) { return $advanced[$key]['desktop']['value'] ?? $fallback; }; $bp_int = function ($key, $bp, $fallback) use ($advanced) { $raw = $advanced[$key][$bp]['value'] ?? null; return (null === $raw || '' === $raw) ? $fallback : self::to_int($raw, $fallback); }; // A count of 0 (possible from converted/imported layouts; the field's // own minimum is 1) makes Swiper size slides as Infinity and they vanish. $slide_count = max(1, self::to_int($val('slideCount', '3'), 3)); $tablet_count = max(1, $bp_int('slideCount', 'tablet', $slide_count)); $phone_count = max(1, $bp_int('slideCount', 'phone', $tablet_count)); $slide_scroll = self::to_int($val('slideToScroll', '1'), 1); $tablet_scroll = $bp_int('slideToScroll', 'tablet', $slide_scroll); $phone_scroll = $bp_int('slideToScroll', 'phone', $tablet_scroll); $space = self::to_int($val('slideSpacing', '10px'), 10); $is_infinite = 'on' === $val('isInfinite', 'on'); // Drag / Swipe per device: Swiper's base value is the phone one, and // the tablet and desktop values ride on the breakpoints when they differ. $swipe_at = self::at_each_device($advanced, 'isSwipe', 'on'); $swipe = [ 'desktop' => 'on' === $swipe_at['desktop'], 'tablet' => 'on' === $swipe_at['tablet'], 'phone' => 'on' === $swipe_at['phone'], ]; $is_swipe = $swipe['phone']; $is_center = 'on' === $val('isCenter', 'off'); $is_vertical = 'on' === $val('isVertical', 'off'); $is_variable = 'on' === $val('isVariableWidth', 'off'); $is_autoplay = 'on' === $val('isAutoplay', 'on'); // Continuous Scroll: the runtime moves the track at a steady speed // itself (runtime.js), so Swiper's loop, autoplay, arrows, dots and // keyboard paging are all off. Swiper still lays the slides out and // handles dragging. It needs the plain slide effect. $effect = self::effect($advanced); // Fade, Cards, Flip and Cube stack or turn single slides. $single_view = in_array($effect, ['fade', 'cards', 'flip', 'cube'], true); $continuous = self::is_continuous($advanced); $reverse = 'on' === $val('reverseDirection', 'off'); $pause_hover = 'off' !== $val('pauseOnHover', 'on'); $stop_interact = 'on' === $val('stopOnInteraction', 'off'); $end_behavior = $val('endBehavior', 'restart'); $controls = self::controls_at_each_device($advanced); $show_nav = in_array(true, $controls['nav'], true); $show_pagi = in_array(true, $controls['pagi'], true); $config = [ 'speed' => self::to_int($val('animationSpeed', '700ms'), 700), 'loop' => $is_infinite && !$continuous, 'grabCursor' => true, 'simulateTouch' => $is_swipe, 'allowTouchMove' => $is_swipe, 'observer' => true, 'observeParents' => true, 'spaceBetween' => $space, // With fewer slides than fit the viewport there is nothing to page // through, so Swiper disables its controls and dragging instead of // rendering dead arrows and a single bullet. 'watchOverflow' => true, // Swiper's a11y module labels the nav buttons, exposes the slide // roles and announces slide changes in a live region. It was never // enabled, so carousels shipped with unlabelled arrows and silent // slide transitions. Keep in lockstep with the JS twin in // src/divi5/shared/carousel/config.js. 'a11y' => [ 'enabled' => true, 'prevSlideMessage' => esc_html__('Previous slide', 'addons-for-divi'), 'nextSlideMessage' => esc_html__('Next slide', 'addons-for-divi'), 'firstSlideMessage' => esc_html__('This is the first slide', 'addons-for-divi'), 'lastSlideMessage' => esc_html__('This is the last slide', 'addons-for-divi'), 'paginationBulletMessage' => esc_html__('Go to slide {{index}}', 'addons-for-divi'), ], // Arrow-key control when the carousel has focus. 'keyboard' => ['enabled' => true, 'onlyInViewport' => true], // Whole-pixel slide sizes and positions. Fractional widths left // images a half pixel off their grid, which reads as a soft edge // and a shimmer while the track moves. 'roundLengths' => true, // Per-slide progress and visibility classes (parallax captions, // the thumbnail strip, the a11y module's visible set). 'watchSlidesProgress' => true, ]; if ($is_vertical) { $config['direction'] = 'vertical'; $config['slidesPerView'] = 1; } elseif ($is_variable) { $config['slidesPerView'] = 'auto'; } else { $config['slidesPerView'] = $phone_count; $config['breakpoints'] = [ 768 => ['slidesPerView' => $tablet_count, 'spaceBetween' => $space], 981 => ['slidesPerView' => $slide_count, 'spaceBetween' => $space], ]; } if (!$is_vertical && !$is_variable && !$continuous) { if ($tablet_scroll !== $slide_scroll || $phone_scroll !== $slide_scroll) { // Slides to Scroll per device. A phone showing one post at a // time with a desktop value of 2 skipped every second post. $config['slidesPerGroup'] = max(1, $phone_scroll); $config['breakpoints'][768]['slidesPerGroup'] = max(1, $tablet_scroll); $config['breakpoints'][981]['slidesPerGroup'] = max(1, $slide_scroll); } elseif ($slide_scroll > 1) { $config['slidesPerGroup'] = $slide_scroll; } } if ($continuous) { // Arrow keys would page a track the runtime is moving; the pause // button and focus pause are the keyboard controls here. $config['keyboard'] = ['enabled' => false]; // A film strip is thrown, not paged: a drag glides to a stop with // momentum instead of snapping to the nearest slide, and the strip // picks up again from there. $config['freeMode'] = [ 'enabled' => true, 'momentum' => true, 'momentumRatio' => 0.6, 'momentumBounce' => false, 'sticky' => false, ]; } if ($is_center && !$is_vertical && !$continuous) { $config['centeredSlides'] = true; $center_mode_type = $val('centerModeType', 'classic'); $center_padding = self::to_int($val('centerPadding', '0px'), 0); if ('classic' === $center_mode_type && !$is_variable && $center_padding > 0) { $config['slidesOffsetBefore'] = $center_padding; $config['slidesOffsetAfter'] = $center_padding; } } if ($show_nav) { $config['navigation'] = ['nextEl' => '.swiper-button-next', 'prevEl' => '.swiper-button-prev']; } if ($show_pagi) { $pagi_type = $val('pagiType', 'dot'); if ('progressbar' === $pagi_type) { $config['pagination'] = ['el' => '.swiper-pagination', 'type' => 'progressbar']; } else { $config['pagination'] = ['el' => '.swiper-pagination', 'clickable' => true]; if ('number' === $pagi_type) { $config['dtqPagiType'] = 'number'; } elseif ('dynamic' === $pagi_type) { // A long row of dots shrinks to the few around the active one. $config['pagination']['dynamicBullets'] = true; $config['pagination']['dynamicMainBullets'] = 1; } } } if (!$continuous && !$is_vertical && 'on' === $val('showScrollbar', 'off')) { $config['scrollbar'] = ['el' => '.swiper-scrollbar', 'draggable' => true, 'snapOnRelease' => true, 'hide' => false]; } // Transition effects. if ('slide' !== $effect) { $config['effect'] = $effect; $slide_shadows = 'off' !== $val('slideShadows', 'on'); if ($single_view) { $config['slidesPerView'] = 1; $config['spaceBetween'] = 0; unset($config['breakpoints'], $config['slidesPerGroup'], $config['centeredSlides'], $config['slidesOffsetBefore'], $config['slidesOffsetAfter']); } if ('fade' === $effect) { $config['fadeEffect'] = ['crossFade' => true]; } elseif ('cards' === $effect) { $config['cardsEffect'] = ['slideShadows' => $slide_shadows, 'rotate' => true, 'perSlideOffset' => 8, 'perSlideRotate' => 2]; } elseif ('flip' === $effect) { $config['flipEffect'] = ['slideShadows' => $slide_shadows, 'limitRotation' => true]; } elseif ('cube' === $effect) { $config['cubeEffect'] = ['slideShadows' => $slide_shadows, 'shadow' => $slide_shadows, 'shadowOffset' => 20, 'shadowScale' => 0.94]; } elseif ('coverflow' === $effect) { // Coverflow is built around a centered active slide. $config['centeredSlides'] = true; unset($config['slidesOffsetBefore'], $config['slidesOffsetAfter']); $config['coverflowEffect'] = [ 'rotate' => self::to_signed_int($val('coverflowRotate', '50deg'), 50), 'depth' => self::to_signed_int($val('coverflowDepth', '100px'), 100), 'stretch' => self::to_signed_int($val('coverflowStretch', '0px'), 0), 'modifier' => 1, 'slideShadows' => $slide_shadows, ]; } } // Gallery options. $rows = self::grid_rows($advanced); if ($rows > 1) { // Row fill keeps the slides' natural height (column fill needs a // fixed carousel height). Swiper's loop cannot run on a // row-filled grid, and a grid has no single slide to center. $config['grid'] = ['rows' => $rows, 'fill' => 'row']; $config['loop'] = false; unset($config['centeredSlides'], $config['slidesOffsetBefore'], $config['slidesOffsetAfter']); } if (!$continuous && 'on' === $val('enableZoom', 'off')) { $config['zoom'] = ['maxRatio' => 3, 'toggle' => true]; } if (!$continuous && 'on' === $val('parallaxCaptions', 'off')) { $config['parallax'] = true; } if (!$continuous && 'on' === $val('showThumbs', 'off')) { // Built by the runtime from the slides' own images (runtime.js). $thumbs = max(1, self::to_int($val('thumbCount', '6'), 6)); $thumbs_tablet = max(1, $bp_int('thumbCount', 'tablet', $thumbs)); $config['dtqThumbs'] = [ 'count' => $thumbs, 'tablet' => $thumbs_tablet, 'phone' => max(1, $bp_int('thumbCount', 'phone', $thumbs_tablet)), 'gap' => max(0, self::to_int($val('thumbGap', '8px'), 8)), ]; } // Free Scroll and Mouse Wheel (Slide by Slide; Continuous Scroll // always glides and leaves the wheel to the page). Free scroll moves // a track, so it needs the plain slide effect. if (!$continuous && 'slide' === $effect && 'on' === $val('freeScroll', 'off')) { $config['freeMode'] = [ 'enabled' => true, 'momentum' => true, 'momentumRatio' => 1, 'momentumBounce' => true, 'sticky' => 'on' === $val('freeScrollSnap', 'off'), ]; } if (!$continuous && 'on' === $val('mousewheel', 'off')) { // forceToAxis: a horizontal carousel only takes horizontal wheel // and trackpad movement, so scrolling down the page is never // captured. releaseOnEdges hands the wheel back at either end. $config['mousewheel'] = ['enabled' => true, 'forceToAxis' => true, 'releaseOnEdges' => true, 'sensitivity' => 1]; if ($is_vertical) { // A looping vertical carousel has no end to release at. $config['loop'] = false; } } // At the last slide, when the loop is off. "restart" is Swiper's // default: autoplay returns to the first slide, the arrows stop. if (!$is_infinite && !$continuous && 'rewind' === $end_behavior) { $config['rewind'] = true; } if ($is_autoplay && !$continuous) { $config['autoplay'] = [ 'delay' => self::to_int($val('autoplaySpeed', '2000ms'), 2000), // Hover, keyboard focus, off-screen and the pause button are // all held by the shared runtime (runtime.js), which owns // pausing. Swiper's own hover pause cannot see those other // reasons and would restart autoplay underneath them. 'pauseOnMouseEnter' => false, // Stop After Interaction is a runtime hold, so the pause // button can start autoplay again. 'disableOnInteraction' => false, 'reverseDirection' => $reverse, 'stopOnLastSlide' => !$is_infinite && 'stop' === $end_behavior, ]; } if ($swipe['tablet'] !== $swipe['phone'] || $swipe['desktop'] !== $swipe['phone']) { foreach ([768 => $swipe['tablet'], 981 => $swipe['desktop']] as $bp => $on) { $config['breakpoints'][$bp] = array_merge($config['breakpoints'][$bp] ?? [], ['simulateTouch' => $on, 'allowTouchMove' => $on]); } } // Settings the runtime reads (stripped before Swiper sees the config). $config['dtqMotion'] = $continuous ? [ 'mode' => 'continuous', 'pauseOnHover' => $pause_hover, // Pixels per second. A floor of 10 keeps a stored 0 from // stopping the strip (and from a zero-length loop). 'pxPerSec' => max(10, self::to_int($val('scrollSpeed', '60px'), 60)), 'reverse' => $reverse, 'stopOnInteraction' => $stop_interact, ] : [ 'mode' => 'step', // Moving content that cannot be paused is a WCAG 2.2.2 // problem; hovering pauses it by default. 'pauseOnHover' => $pause_hover, 'stopOnInteraction' => $stop_interact, ]; return ['config' => $config, 'show_nav' => $show_nav, 'show_pagi' => $show_pagi]; } /** * Inline custom properties that lay the slides out before Swiper starts. * * Read from the built config, so the counts are the ones Swiper will use. * Returns an empty string for layouts the pre-init row cannot predict * (vertical, variable width, centered, effects other than slide, rows). * The rules live in src/divi5/shared/carousel/carousel.scss. * * @param array $config A config from build_swiper_config(). * * @return string A leading-space ` style="..."` attribute, or ''. */ public static function pre_init_style($config) { if (!is_array($config) || !isset($config['slidesPerView']) || !is_int($config['slidesPerView']) || isset($config['direction']) || !empty($config['centeredSlides']) || (isset($config['effect']) && 'slide' !== $config['effect']) || isset($config['grid']) ) { return ''; } $phone = max(1, (int) $config['slidesPerView']); $tablet = max(1, (int) ($config['breakpoints'][768]['slidesPerView'] ?? $phone)); $desktop = max(1, (int) ($config['breakpoints'][981]['slidesPerView'] ?? $tablet)); $gap = max(0, (int) ($config['spaceBetween'] ?? 0)); return sprintf( ' style="%s"', esc_attr(sprintf('--dtq-slides:%1$d;--dtq-slides-tablet:%2$d;--dtq-slides-phone:%3$d;--dtq-gap:%4$dpx', $desktop, $tablet, $phone, $gap)) ); } /** * Render an arrow button with its icon glyph. * * @param array $advanced The module advanced attrs. * @param string $which 'prev' or 'next'. * * @return string */ public static function render_arrow($advanced, $which) { $is_prev = 'prev' === $which; $icon = $advanced[$is_prev ? 'iconLeft' : 'iconRight']['desktop']['value'] ?? ''; $glyph = self::resolve_arrow($icon, $is_prev ? '4' : '5'); if (function_exists('dtq_inject_fa_icons') && !empty($icon)) { $uni = is_array($icon) ? ($icon['unicode'] ?? '') : explode('||', (string) $icon)[0]; dtq_inject_fa_icons($uni . '||' . $glyph['font'] . '||' . $glyph['weight']); } return sprintf( '
', esc_attr($which), esc_attr($glyph['font']), esc_attr($glyph['weight']), esc_html($glyph['char']) ); } /** * Markup for the optional controls: the pause button and autoplay progress * bar sit inside `.swiper` (over the slides), the scrollbar after it. * Mirrors renderCarouselControls() in renderArrows.jsx; the runtime * (runtime.js) wires them up. * * @param array $advanced The module advanced attrs. * * @return array ['inner' => string, 'after' => string] */ public static function render_controls($advanced) { $val = function ($key, $fallback) use ($advanced) { return $advanced[$key]['desktop']['value'] ?? $fallback; }; $autoplay = 'on' === $val('isAutoplay', 'on'); $continuous = self::is_continuous($advanced); $vertical = 'on' === $val('isVertical', 'off'); $inner = ''; if ($autoplay && 'on' === $val('showPauseButton', 'off')) { $position = $val('pausePosition', 'top-right'); if (!in_array($position, ['top-right', 'top-left', 'bottom-right', 'bottom-left'], true)) { $position = 'top-right'; } $pause = esc_html__('Pause the carousel', 'addons-for-divi'); $inner .= sprintf( '', esc_attr($position), esc_attr($pause), esc_attr(esc_html__('Play the carousel', 'addons-for-divi')) ); } if ($autoplay && !$continuous && 'on' === $val('showAutoplayProgress', 'off')) { $inner .= ''; } $after = (!$continuous && !$vertical && 'on' === $val('showScrollbar', 'off')) ? '' : ''; if (!$continuous && 'on' === $val('showThumbs', 'off')) { // Filled by the runtime from the slides' images. $after .= '