Problem/Motivation
In #2895382: Hide label, thumbnail, etc. for default display of media file and image references we have improved the "Default" view display for media entities of type image, showing only the image:
At that point in time the name wasn't configurable in the display. In #2912298: Make media name available on manage display we added the possibility to configure the name, but we didn't set the shipped configuration to hide it by default.
Proposed resolution
Hide the media name for media images in the default configuration.
There is a change to media.html.twig but it brings it into line with the one in Stable, so no API break for themes using Stable.
With the current configuration:
Proposed configuration:
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#40 | interdiff-33-40.txt | 2.24 KB | marcoscano |
#40 | 2930788-40.patch | 10.67 KB | marcoscano |
#33 | interdiff-31-33.txt | 1.86 KB | marcoscano |
#33 | 2930788-33.patch | 10.68 KB | marcoscano |
#31 | interdiff-27-31.txt | 5.19 KB | marcoscano |
Comments
Comment #2
BerdirI think in most cases you don't want to have that name shown at all, so maybe that's what we should do by default?
If you want to have a visible text, then it's likely an additional description/caption field or so, the name is something that is mostly just used in the backend.
Comment #3
marcoscano@Berdir man you are fast! :)
I was just about to mention here that for accuracy's sake the original issue (#2895382: Hide label, thumbnail, etc. for default display of media file and image references) created the default without the name, and it was added to the display later, when we wanted to "make the name availbale for being configured", in #2912298: Make media name available on manage display.
So I believe what makes more sense is to hide it again here.
Comment #4
BerdirYou can have it configurable and hidden by default by just using ->setDisplayConfigurable('view', TRUE) without having a ->setDisplayOptions('view') call, so that might be an option?
Comment #5
marcoscanoI guess this is a bug then. Updated the IS accordingly.
Comment #6
marcoscanoTrue, that's probably a better solution, I'll change the patch to use that.
Comment #7
BerdirYou want both. Your patch does it for the image media type, what I wrote is to have that the default when creating a new media type and the view display is initially created from the base field definitions.
Comment #9
marcoscanoTrue, thanks!
Comment #11
marcoscanoTestbot hiccup
Comment #12
phenaproximaShould we have a test of this?
Comment #13
marcoscanoHow about this?
Comment #14
seanBI think we should also add a test to verify it is actually hidden for the image media type. Maybe just add it to
MediaSourceImageTest
?Comment #15
phenaproximaI was thinking that we should test it functionally, by actually adding a media item, then visiting that item and asserting that its name does not appear...
Comment #16
seanBWhile looking at it this morning, I noticed we don't have a functional media display test yet? So we might want to add
MediaDisplayTest
. I started working on something but got distracted, so let me share what I started.The media name is shown as the page title on the media detail page, so the assert should be changed to check for the name field by class/ID or something.
Comment #17
Berdir+1 to a test like that, that would also have failed on #2775131: Media entities should support contextual links
Comment #18
marcoscanoAs mentioned in #2931057-7: Media template should use 'name' instead of 'label', it doesn't make much sense to have the label in the template, now that it is configurable in the display.
This patch removes it entirely from the template, and adds some tests for some scenarios.
Feedback welcome.
Comment #19
marcoscanoStarted as a Functional test, then moved to FunctionalJavascript, and forgot to move the file and update the namespace. Done now.
Comment #21
BerdirWhat about the template in stable and classy?
We already started a discussion about changing this or not in the contextual links issue.
I'm also still not sure what the meaning of title_prefix and suffix is. I thought it is about contextual links, but actually, while we have *tons* of templates with that, I can only see one usage of it and that's some shortcut thing.
Comment #22
marcoscanoUnless I'm looking at the wrong place, stable and classy templates are already without the hardcoded title:
http://cgit.drupalcode.org/drupal/tree/core/themes/stable/templates/cont...
http://cgit.drupalcode.org/drupal/tree/core/themes/classy/templates/cont...
so this patch in fact would be unifying them in this regard.
We mentioned this in slack as well, that removing this here would probably mean that it would be harder to fix the contextual links issue, but we kind of agreed that it was a different issue, to be solved there after this one is fixed. Based on #2775131-38: Media entities should support contextual links, I would assume the contextual links could still be done in that scenario though.
(Not sure if I got your point correctly, sorry if that was the case)
Comment #23
seanBShould we add a test to verify the display of media in an entity reference field? I think we should verify the media name is not added there.
Comment #24
marcoscanoThat's a good idea, here it is.
Comment #25
marcoscanoNot really image-only anymore.
Comment #26
seanBThanks @marcoscano, we needed this :).
Could we add 1 more assert, for the image media referenced in the node, that the media name is 100% not in the page? We now have an assert for the name field, but if someone adds the H2 again in another issue we might not catch that?
Comment #27
marcoscanoSure, that's a good idea!
Thanks!
Comment #28
phenaproximaI think this looks really good. I have a few suggestions, but they really are just suggestions and don't need to block RTBC.
Ye gods. This slows things down to a crawl; is there any possible chance of using the testing profile instead?
Let's add a comment explaining what this is doing.
Didn't we have an issue open at some point to wrap media items in div tags, not article tags? If so, we should probably loosen or change this selector in the name of future proofing.
Also, I believe we can rewrite this to harden the assertions a little:
Nit: 'base field' should be two words, and 'name' should be quoted.
Comment #29
Berdir1. The config is in standard, so we kind of have to test that.
Comment #30
phenaproximaYes, but we could install Testing, read the config from Standard, and create it in the test's setUp() method. Installing all of Standard seems like overkill.
Comment #31
marcoscanoThanks for reviewing @phenaproxima!
This should address #28.
Comment #32
phenaproximaThanks, @marcoscano! I have but nitpicks, and then this is RTBC.
We don't need this check; we know that Standard's optional config directory exists, and it'd be a serious problem if it didn't. :)
FileStorage's constructor already specifies StorageInterface::DEFAULT_COLLECTION as its default second argument, so we don't need to pass it here.
Let's use entity_get_display() here, since it's more robust.
Comment #33
marcoscanoThanks for reviewing @phenaproxima !
Comment #35
marcoscanoComment #36
seanBSeems like everything is addressed. Nice work @marcoscano!
Comment #38
phenaproximaAPCU out-of-memory failures are not real failures. Back to RTBC.
Comment #39
catchJust some nits.
Just noting this was discussed in #21/22 and the Stable theme already doesn't have this hunk, so it's OK to remove here and won't affect themes using Stable.
Install
Could lose the 1) and 2) here, I don't think they add much.
And again here.
Comment #40
marcoscanoThanks @catch for reviewing!
This should address #39.
Comment #41
phenaproximaNice and clean. RTBC when testbot smiles upon it.
Comment #43
phenaproximaTestbot random failed again. Back to RTBC.
Comment #45
catchCommitted 26235da and pushed to 8.5.x. Thanks!
Comment #47
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedThis issue relates to #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI which I am working on hopefully for 8.6.
I think that the net result of this check-in leaves some problems:
The issue I am working on will solve these problems. I would welcome comment from participants in this thread
Comment #48
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedUpdate: the last comment was not entirely correct.
New issue that is relevant here: #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI. My findings are that when viewing /media/NN:
Hence an unexpected side-effect of this commit is that it changes the default behaviour from 1) to 2).
Comment #49
jonathanshawI think the new issue @AdamPS meant to link to was actually #2941208: Title formatting broken due to flawed EntityViewController->buildTitle
Comment #50
AdamPS CreditAttribution: AdamPS at AlbanyWeb commented@jonathanshaw oops thanks for the correction