Have a fallback for mobile disabled lightboxes

Created on 7 June 2025, 5 months ago

Problem/Motivation

I use slick carousel (and in some projects splide but thanks to gausarts most of the settings are the same) with the Media switch option set to colorbox. In colorbox module settings I enabled the mobile detection option so colorbox doesn't load on mobiles. In fact it doesn't make sens to have open colorbox to show a bigger image on a mobile which screen has already a full width image.

My media field supports image, video, remote video and audio files. It is very common in my use case to have a mix of these media and this works nice on desktop: preview images are shown in slick carousel and medias opening in colorbox when the preview image is clicked.

And here comes the problem in mobile display. As colorbox is disabled, clicking on the preview image opens the remote url, not the local media embedding the remote source, as we can see in the html below.

<a href="https://www.youtube.com/watch?v=ABCDeFg" class="blazy__colorbox litebox litebox--multimedia cboxElement is-b-cbox" data-colorbox-trigger="" data-oembed-url="/media/oembed?url=https%3A//www.youtube.com/watch%3Fv%3DABCDeFg&amp;max_width=0&amp;max_height=0&amp;hash=etc....>
 <picture>
                  <source etc

What I would like ? Instead of using the url attribute on click, i.e. "https://www.youtube.com/watch?v=ABCDeFg" which makes user leave the site, use the data-oembed-url, i.e. "/media/oembed?url=https%3A//www.youtube.com/watch%3Fv%3DABCDeFg"

A better solution would be to not even have to click (no tag) and just display a mobile view mode that can be set for each media in "admin/structure/media/manage". As said in the intro it makes no sens to have to have a link to a bigger image on a mobile which screen has already a full width image. Currently, when Media switcher is set to "none" all types of media display nice in slides but we have no control on them. But the most important is to check if colorbox is loaded and if not have a fallback to Media switcher "none".

Perhaps this is doable with some parameter adjustments, but I haven't been able to locate them.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France erwangel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024