@php /** * Before/after image-compare shortcode. * * Styles: * style-default — single centered heading + draggable compare slider with * Before/After labels (original behavior, unchanged). * style-2 — full-bleed dual-caption layout, NO draggable handle, NO * Before/After labels. Mirrors html/home-headphone.html * lines 2947-2966: `container-full > banner-image-compare * style-2 > img-viewer-compare-wrap image-compare` (two * img-comp) + `wrap-content` (LEFT + RIGHT captions). * * @var \Botble\Shortcode\Compilers\Shortcode $shortcode */ $allowed = ['style-default', 'style-2']; $style = in_array($shortcode->style ?? '', $allowed, true) ? $shortcode->style : 'style-default'; $beforeImage = $shortcode->before_image ?? ''; $afterImage = $shortcode->after_image ?? ''; $heading = $shortcode->heading ?? ''; $subheading = $shortcode->subheading ?? ''; $beforeLabel = $shortcode->before_label ?: __('Before'); $afterLabel = $shortcode->after_label ?: __('After'); $orientation = in_array($shortcode->orientation ?? '', ['horizontal', 'vertical'], true) ? $shortcode->orientation : 'horizontal'; $sliderColor = $shortcode->slider_color ?: '#ffffff'; $position = (int) ($shortcode->slider_position_percent ?? 50); $position = max(0, min(100, $position)); // style-2 dual-caption knobs. $leftHeading = trim((string) ($shortcode->left_heading ?? '')); $leftDesc = trim((string) ($shortcode->left_desc ?? '')); $rightHeading = trim((string) ($shortcode->right_heading ?? '')); $rightDesc = trim((string) ($shortcode->right_desc ?? '')); // Bail-out: without both images the slider has nothing to compare. Render // an admin-only hint so editors notice the misconfiguration in the page builder. $missingImages = empty($beforeImage) || empty($afterImage); @endphp @if ($missingImages) @if (function_exists('is_in_admin') && is_in_admin())
{{ __('Please choose both a before and an after image.') }}
@endif @elseif ($style === 'style-2') {{-- home-headphone §7: full-bleed dual-caption compare. The image-compare-viewer JS sizes the wrapper to the first image's natural dimensions — no forced aspect-ratio (matches the demo, which only constrains .img-comp on mobile via the shared theme CSS). --}}
htmlAttributes() !!} class="banner-image-compare style-2">
{{-- Original images — NOT a cropped RvMedia size; the compare art is a wide banner and must render at its natural aspect. --}} {!! RvMedia::image($beforeImage, $leftHeading ?: __('Before'), null, false, ['class' => 'img-comp', 'loading' => 'lazy', 'width' => 1920, 'height' => 720]) !!} {!! RvMedia::image($afterImage, $rightHeading ?: __('After'), null, false, ['class' => 'img-comp', 'loading' => 'lazy', 'width' => 1920, 'height' => 720]) !!}
@if ($leftHeading !== '')

{!! BaseHelper::clean($leftHeading) !!}

@endif @if ($leftDesc !== '')

{!! BaseHelper::clean($leftDesc) !!}

@endif
@if ($rightHeading !== '')

{!! BaseHelper::clean($rightHeading) !!}

@endif @if ($rightDesc !== '')

{!! BaseHelper::clean($rightDesc) !!}

@endif
@else @if (! empty($heading) || ! empty($subheading))
@if (! empty($heading))

{!! BaseHelper::clean($heading) !!}

@endif @if (! empty($subheading))

{!! BaseHelper::clean($subheading) !!}

@endif
@endif {{-- .banner-image-compare aspect-ratio clamp (1920 / 720) lives in assets/sass/component/_inline-migrated.scss. Init handled by image-compare-viewer.js (class-based). --}}
htmlAttributes() !!} class="banner-image-compare img-viewer-compare-wrap image-compare wow fadeIn" data-orientation="{{ $orientation }}" data-control-color="{{ $sliderColor }}" data-start-position="{{ $position }}" data-label-before="{{ $beforeLabel }}" data-label-after="{{ $afterLabel }}" > {!! RvMedia::image($beforeImage, $beforeLabel, 'hero-banner', false, ['class' => 'img-comp', 'loading' => 'lazy', 'width' => 1920, 'height' => 720]) !!} {!! RvMedia::image($afterImage, $afterLabel, 'hero-banner', false, ['class' => 'img-comp', 'loading' => 'lazy', 'width' => 1920, 'height' => 720]) !!}
@endif