Problem/Motivation

I'm using GLightbox with EPT Image Gallery and would like an option in the settings form to choose a skin name. This would make it easier to apply site-specific styling to the lightbox including navigation and close controls.

The JavaScript library supports a skin option that adds a CSS class to the lightbox. The existing hook_glightbox_settings_alter() can supply this in code.

Proposed resolution

Add a Skin text field under Custom options and pass the value to Glightbox's skin option. Use GLightbox’s existing default skin (clean) when no custom skin name is entered. Help text could explain that the site's theme supplies the custom CSS.

AI Usage

I used AI to double check my work / check the existing settings.

Comments

bdunphy created an issue. See original summary.

bdunphy’s picture

Issue summary: View changes

  • levmyshkin committed 250297cc on 1.0.x
    feat: #3641361 Expose the GLightbox skin option in the settings form...
levmyshkin’s picture

Assigned: Unassigned » levmyshkin
Status: Active » Fixed

Thanks for the clear proposal, @bdunphy. This is committed to 1.0.x (250297c) and released in GLightbox 1.0.22.

What changed:

  • A new Skin text field in the Custom options at Configuration > Media > GLightbox. The value is passed to GLightbox's skin option, which adds the class glightbox-SKIN to the lightbox. An empty value falls back to the library's default clean skin.
  • The help text explains that only clean is styled by the GLightbox library, so any other skin needs CSS from your theme.
  • Only letters, numbers, hyphens and underscores are accepted, because the value becomes part of a CSS class name.
  • glightbox_update_10001() adds skin: clean to existing sites, so please run drush updb after updating.
  • While testing with EPT Image Gallery, I found that changes to GLightbox settings did not reach pages that were already render-cached until a full cache rebuild, because the attached settings had no config:glightbox.settings cache tag. That tag is now added, so a new skin (or any other setting) applies as soon as you save the form.

Example: select "Custom" options, enter dark as the skin, and style .glightbox-dark in your theme. You no longer need hook_glightbox_settings_alter() for this.

Kernel and functional tests cover the new setting, and I checked it manually with an EPT Image Gallery paragraph.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

bdunphy’s picture

@levmyshkin - thank you so much for adding this feature.