The original issue with a first approach was:
✨
Add gallery grouping options
Closed: won't fix
But that logic wasn't very flexible and we have to think about this very well.
Expected behaviour:
Grouping must be very flexible to allow for example grouping by page, entity, field, item, ... anywhere, for example using fences or a twig override or a setting.
Current behaviour:
Currently, we're looking for a photoswipe-gallery in JavaScript using .closest()
around each photoswipe item. If a gallery around the photoswipe link is already existing, there's nothing left to do.
If there's no grouping, we're adding the wrapper around each single element in JS.
Why so complicated?
As JS runs late (for Photoswipe initialization), it's irrelevant where we set the class before. This is much more flexible as in former times, where it was set in PHP code.
Anyway, it would still be helpful if we COULD configure grouping by a setting.
The problem is, that the field formatter, by logic, can only set the grouping per field or per item, but not for levels above.
And we shouldn't set the behavior as a global setting, at it might depend per entity type or even field.
So this task is about discussing how to solve this most flexible for all possible kinds of photoswipe implementation, even custom ones.
Also we should have a look how similar modules solve this. For example
https://www.drupal.org/node/266126 →
a) Add a setting in the field formatter (where you'd expect it), but set grouping disabled by default, so it can also be set at any other level using fences, twig or whatever. Maybe set "Global setting" as default to define this global default.
Options could be:
b) ??
Furthermore we should definitely remove the hard-coded photoswipe-gallery wrapper, which changes Drupals default field structure (in src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php):
if (!empty($items) && count($items) > 1) {
// If there are more than 1 elements, add the gallery wrapper.
// Otherwise this is done in javascript for more flexibility.
$elements['#prefix'] = '<div class="photoswipe-gallery">';
$elements['#suffix'] = '</div>';
}
and makes it hard to overwrite the wrapping!
See https://git.drupalcode.org/project/photoswipe/-/commit/6d6c3efff936599db... (D7) and the major issue introduced that way:
#3179987: Grouping & thereby navigation buttons missing in 2.x-beta6+ →
which should not happen again. Anyway we might solve it similarly in 5.x like in Drupal 7 at the end of the issue?
Needs work
5.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.