Problem/Motivation

The lightbox_theme() hook in lightbox.module declares a theme hook named lightbox_formatter, which makes Drupal look for templates/lightbox-formatter.html.twig.

However, the template shipped with the module is named lightbox-image-formatter.html.twig (which corresponds to a lightbox_image_formatter theme hook). This mismatch causes a Twig loader error.

Steps to reproduce

  1. Install and enable the Lightbox module
  2. Configure an image field to use the Lightbox image formatter
  3. View a content entity with that field

The following error is thrown:

Twig\Error\LoaderError: Template "modules/contrib/lightbox/templates/lightbox-formatter.html.twig" is not defined in "field.html.twig" at line 75. in Twig\Loader\ChainLoader->getCacheKey() (line 75 of themes/contrib/bootstrap5/templates/field/field.html.twig)

Proposed resolution

Rename the template lightbox-image-formatter.html.twig to lightbox-formatter.html.twig to match the existing theme hook.

Issue fork lightbox-3577497

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

dpiet created an issue. See original summary.

dpiet’s picture

Status: Active » Needs review
dpiet’s picture

Issue summary: View changes
dpiet’s picture

Status: Needs review » Needs work
dpiet’s picture

Status: Needs work » Needs review
mably’s picture

Status: Needs review » Reviewed & tested by the community

  • mably committed b9d0581b on 1.x authored by dpiet
    fix: #3577497 Missing template lightbox-formatter.html.twig causes Twig\...
mably’s picture

Status: Reviewed & tested by the community » Fixed

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.