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
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
Comment #3
mattlc commentedTested locally on both images and "custom" assets.
Comment #5
keepeek_dam commentedComment #7
mattlc commented@keepeek_dam as this is closed, could you please credit me for this contribution ?
Comment #8
mattlc commentedComment #9
keepeek_dam commentedI update the issue, is it good from your side mattlc ?
Comment #10
mattlc commentedGreat ! Thank you very much :)