Problem/Motivation

The KeepeekSource media plugin resolves a formatter from core.entity.view_display.media.[BUNDLE].default config to retreive a formatter class name and call "deriveMediaDefaultNameFromUrl()" on this formatter if no "title" value found in json.

This creates a strong coupling between the source and the view display. Site builders are not able to configure the default view display as they may want without affecting the module stability.

Proposed resolution

As the deriveMediaDefaultNameFromUrl() is a static method, just call it from the KeepeekSource like this :

return KeepeekFormatterBase::deriveMediaDefaultNameFromUrl($url);

To allow other modules to alter it, dispatch an event with the source configuration, the media entity and the json and use its result (if not empty).

I don't think a plugin manager would be usefull here because the processing if json data would be hard to make configurable and I don't see any situation that a contrib module would provide such alter feature without requiring the keepeek module.

Issue fork keepeek-3530936

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

mattlc created an issue. See original summary.

mattlc’s picture

Assigned: mattlc » Unassigned
Status: Active » Needs review

Tested locally on both images and "custom" assets.

keepeek_dam made their first commit to this issue’s fork.

keepeek_dam’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

mattlc’s picture

@keepeek_dam as this is closed, could you please credit me for this contribution ?

mattlc’s picture

keepeek_dam’s picture

I update the issue, is it good from your side mattlc ?

mattlc’s picture

Great ! Thank you very much :)