Replace hardcoded Media Photoswipe view mode with configurable formatter

Created on 22 July 2025, about 2 months ago

Problem/Motivation

The Media Gallery module uses a custom Media Photoswipe view mode to display the image field (`field_images`) on gallery entities. This view mode:
- Is not easily customizable by site builders from the UI
- Is not using the existing configurable field formatter provided by [Photoswipe field formatter]( https://www.drupal.org/project/photoswipe β†’ ).

Steps to reproduce

1. Install and enable the Media Gallery module.
2. Create a media gallery entity and add media items with images.
3. Go to the Structure -> Media Gallery -> Manage View Display
4. Observe that the "Rendered Entity" Format and "Media Photoswipe View Mode" is used to render `field_images` but this does not expose any configurability for Photoswipe to the user.
5. Switch the Format to the the [Photoswipe field formatter]( https://www.drupal.org/project/photoswipe β†’ ) module.
6. Save the formatting
7. Go to a gallery and observe that the photoswipe gallery is not rendered correctly.

Proposed resolution

- Update the default configuration for `field_images` to use the `photoswipe_field` formatter plugin instead of the `Rendered Entity` formatter.

- Implement a `hook_post_update_NAME()` function that:
- Scans all `entity_view_display` configs for `media_gallery` entities.
- Replaces the formatter for `field_images` with `photoswipe_field` if it still uses the default `Media Photoswipe` view
mode and Rendered Entity formatter.
- Applies reasonable default settings for the Photoswipe formatter (e.g., image style).
- If present and unused, delete the `Media Photoswipe" view mode and its associated display config to avoid conflicts.

Remaining tasks

- [x] Open this issue.
- [ ] Submit merge request/patch
- [ ] Code Review

User interface changes

No user-facing UI changes. Admins may notice the Photoswipe formatter used by default on the `field_images` field when editing view displays.

API changes

None.

Data model changes

No changes to field storage or entity schema. The update modifies field display configuration and removes a view mode config entity (`core.entity_view_display.media.image.media_photoswipe`, `core.entity_view_display.media.media_photoswipe`)

✨ Feature request
Status

Active

Version

3.0

Component

Default

Created by

πŸ‡ΊπŸ‡ΈUnited States circuitcipher

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