Allow caption to use title and description

Created on 14 November 2024, 2 months ago

Problem/Motivation

Right now, the caption calculated for this module is used only as the title but glightbox seems to support description as well: https://github.com/biati-digital/glightbox?tab=readme-ov-file#examples

The way this is implemented right now is slightly problematic because the title does not support HTML and it renders with it in the title of the link even when hovering.

Steps to reproduce

Add caption that has HTML on it.

Proposed resolution

On one side, ensure that there's no HTML returned by _glightbox_formatter_get_caption, by using a strip_tags call on the caption calculated.

Additionally, and in order to not to have to migrate existing configuration or add a breaking change, add a Caption Description option in the formatter, that renders with HTML in the way that the glightbox library supports:

<!-- Advanced Description -->
<a href="large.jpg" class="glightbox5" data-glightbox="title: My title; description: .custom-desc1">
  <img src="small.jpg" alt="image" />
</a>

<div class="glightbox-desc custom-desc1">
  <p>The content of this div will be used as the slide description</p>
  <p>You can add links and any HTML you want</p>
</div>

Happy to work on this if this is an acceptable change.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇪🇸Spain pcambra Asturies

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024