Problem/Motivation

This module includes the GLightbox library from packagist, which is great, but then the library itself uses CDN to load plyr.io by default.

Proposed resolution

Load the GLightbox object using custom options to mark what the location of the plyr.io library is (if found).

Remaining tasks

Add a plyr.io library that falls back to CDN.
If the library is present locally, use that in the glightbox.js main file.

Working on a patch.

Issue fork glightbox-3487303

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pcambra created an issue. See original summary.

pcambra’s picture

Status: Active » Needs review

I've just seen that the plyr.io library requires two hardcoded files from the CDN: https://github.com/sampotts/plyr/blob/a148e2e5b6eb4cda1d63a21397636a365f... that glightbox js library doesn't allow to customise, so in order to avoid those svg/mp4 calls remotely, an additional PR to https://github.com/levmyshkin/glightbox/blob/ec02687a888436767b2800f949a...

levmyshkin’s picture

StatusFileSize
new22.21 KB

Hi pcambra, thank you for your MR! I didn't realize that GLightbox uses 3rd party player, I thought it was native video player. I'd prefer to fork plyr video player, the lastest release was in 24th March 2023, I don't think that it will be updated often. Usually I pull releases in forked repository it didn't take too much time.

Also we need to keep ability to download this Plyr player locally to make it's working without internet access. I'm going also add settings for Plyr player in GLightbox main settings form.

levmyshkin’s picture

Btw I will test your MR and merge it first tomorrow.

  • levmyshkin committed 0b0c8501 on 1.0.x authored by pcambra
    Issue #3487303: GLightbox is very opinionated on including libraries as...

  • levmyshkin committed 65814db4 on 1.0.x
    git commit -m 'Issue #3487303 by pcambra, levmyshkin: Add levmyshkin/...
levmyshkin’s picture

I merged your request and forked plyr library. It will download plyr library automatically with composer now. One I got error for getting paths with LibrariesDirectoryFileFinder, it returns 'library/plyr' path without slash at the beginning. It must be 'root' folder before, but there is no root prefix for my local site. I added '/' manually, which will be working for 99% of sites, but I think it will break base path for site in folder.

files folder

error

error

I released v1.0.12, ping me if you will have any problems with update. Since it was added a new argument in construction caches must be cleared after update.

levmyshkin’s picture

I will test site in folder with /base_path/ root and add settings for Plyr in GLightbox settings form later.

levmyshkin’s picture

Status: Needs review » Fixed
levmyshkin’s picture

Status: Fixed » Closed (fixed)
levmyshkin’s picture

Demo page is working fine after update:
https://drupalbook.org/ept/demo/video-and-image-gallery

pcambra’s picture

That was amazingly fast, many thanks levmyshkin!!!

The only issue we might have is upstream on the glightbox library: https://github.com/biati-digital/glightbox/blob/master/src/js/glightbox....

There's no way to configure two items that come directly from cdn on plyr: https://github.com/sampotts/plyr/blob/a148e2e5b6eb4cda1d63a21397636a365f...

One is a blank mp4 which loads conditionally but the other is the player button svg, and I can see people wanting to change that.

I was going to open an issue there but saw this message: https://github.com/biati-digital/glightbox/issues/472

levmyshkin’s picture

Hi pcambra, I added settings for plyr on GLightbox config form:
/admin/config/media/glightbox

I also forgot, that GLightbox has alter hook_glightbox_settings_alter(), where all settings are possible to change in custom module.
/modules/custom/glightbox/glightbox.api.php

Released the changes in 1.0.13 version.

pcambra’s picture

Yes, but I don't think the mp4 and the svg are configurable (see the links on #13)