Problem/Motivation
Media entities have the text field "Name" by default. It would be handy to be able to select this as the caption source.
This was mentioned before but I'm not sure what the resolution was. #2900638: Caption Text from Media Name not Working
Steps to reproduce
Proposed resolution
Provide a "Name" option in the caption dropdown. Alternatively, it could provide a list of compatible fields from the media entity as options like it does with the parent entity.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork photoswipe-3305887
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
imclean commentedComment #4
anybodyHi @imclean,
thank you for your suggestion!
I added some comments. I'm not general against adding this, but the way we're planning to go here is to remove such select values in favor of the token solution.
So could you please check if this already works via tokens or if there's a way to provide the parent entity tokens, if there's a parent entity? That would be more flexible and then no more limited on the name.
Comment #5
imclean commentedI did try tokens first. To get the media field values from the node I need to drill down but tokens for the reference field require a specific delta, which isn't useful.
Media and file tokens don't help here either as the context is the node itself.
"Name" is a standard media field which can't be removed so it seems OK to include a specific option to use it.
Comment #6
anybodyI added some more comments.
But
->label()returns the same?Comment #7
imclean commentedIt seems to. When I first added the option,
->label()returned null. I'm not sure why, maybe a cache issue. It is now returning whatever is entered in the "Name" field of the media entity. I've changed the values a few times to test it.Comment #8
imclean commentedThe media entity docs I linked to earlier confirms it. https://api.drupal.org/api/drupal/core%21modules%21media%21src%21Entity%...
The "label" entity key for a media entity is "name".
Comment #9
imclean commentedI think this is the correct dev branch.
Comment #10
imclean commentedComment #11
anybodyThanks @imclean,
LGTM!
Comment #13
grevil commentedThx @imclean! Works as expected, for both the field formatter, aswell as the responsive field formatter!
Merging this to dev!