Problem/Motivation

Media installs the File and Image Media Types by default. The default displays include some fields that probably do not need to be shown:

default File display
creation date, author seem of little relevance, since most media are not actually created by the user who uploaded it
The "File" label above the file field formatter does not add information in the visual display, but it will help screen reader users understand the page content semantically.
default Image display
creation date, author seem of little relevance, since most media are not actually created by the user who uploaded it
the thumbnail is just displaying the same image as is displayed again just below it, only much bigger!

Proposed resolution

  1. Change their defaults, so they look like this:
    default File display
    only a simple file representation: a clickable link, preceded by the corresponding file type icon (if any)
    default Image display
    only a clickable thumbnail, linking to the actual file

    (See #3.)

Remaining tasks

None.

User interface changes

See proposed resolution.

API changes

None.

Data model changes

None.

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

wim leers’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new116.11 KB
new185.72 KB
new3.14 KB

I propose these alternative default configuration files, which solve the following problems:

default File display
creation date, author seem of little relevance, since most media are not actually created by the user who uploaded it
the thumbnail is broken, because \Drupal\media\Plugin\Field\FieldFormatter\MediaThumbnailFormatter uses extends \Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter and pretends it works for everything, even though it only works for images… (field_types = {"entity_reference"} vs field_types = {"image"})
"File" label above the file field formatter… that's rather pointless
default Image display
creation date, author seem of little relevance, since most media are not actually created by the user who uploaded it
the thumbnail works in this case, but it's just displaying the same image as is displayed again just below it, only much bigger!

So the proposed alternatives:

default File display
only a simple file representation: a clickable link, preceded by the corresponding file type icon (if any)
default Image display
only a clickable thumbnail, linking to the actual file
wim leers’s picture

Title: Default File & Image displays look broken » Default File & Image displays look broken + remove MediaThumbnailFormatter because it's broken
Assigned: wim leers » Unassigned
Issue summary: View changes
Issue tags: +Usability
Related issues: +#2831274: Bring Media entity module to core as Media module
StatusFileSize
new6.93 KB
new10 KB

the thumbnail is broken, because \Drupal\media\Plugin\Field\FieldFormatter\MediaThumbnailFormatter uses extends \Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter and pretends it works for everything, even though it only works for images… (field_types = {"entity_reference"} vs field_types = {"image"})

I think this means we must remove MediaThumbnailFormatter, since it can very easily result in completely broken output. Plus, it's not clear what purpose it would serve.

Note: if we want to do this in a separate issue, I'm happy to do that too. But the patch in #3 is already removing the only references to this. And there apparently is zero test coverage for this. (We apparently missed that in #2831274: Bring Media entity module to core as Media module.)

marcoscano’s picture

Status: Needs review » Needs work

+1 for removing the formatter.
In this case, however, we may need to update the CR (or create a new one) because some contrib modules may be relying on it (I personally don't think many are, but just in case).

I have manually tested #4, everything works as expected. I was going to RTBC but just found that we have:

field.formatter.settings.media_thumbnail:
  type: field.formatter.settings.image
  label: 'Media thumbnail field display format settings'

inside media.schema.yml. Shouldn't we remove it as well?

chr.fritsch’s picture

Status: Needs work » Needs review
StatusFileSize
new10.3 KB
new424 bytes

I removed field.formatter.settings.media_thumbnail from the media.schema.yml.

marcoscano’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @chr.fritsch! RTBC'ing in the assumption tests will pass.

wim leers’s picture

#5: So glad you caught that!

dawehner’s picture

+++ /dev/null
@@ -1,201 +0,0 @@
- */
-class MediaThumbnailFormatter extends ImageFormatter {
-

Is there a reason we couldn't fix the thumbnail formatter instead? The thumbnail is guaranteed to be a valid URI, so I don't see why it shouldn't be theoretically possible to render an img tag to that. In case it isn't, is there any value in the thumbnail in the first place, when you cannot display it? Could we remove it across the entire module as well? This would be a great simplification.

Default File & Image displays look broken + remove MediaThumbnailFormatter because it's broken

The usage of the word "broken"

marcoscano’s picture

StatusFileSize
new51.9 KB

Re: #9:
I may be missing the point (sorry if it's the case), but isn't the thumbnail a basefield of type image, and then, viewable by any formatter that can be applied to image fields?

Out of the box, we are indeed using the Tumbnail information in the Media listing in /admin/content/media:

Media listing

so I see value in having the basefield, even if the formatter is gone.

wim leers’s picture

Title: Default File & Image displays look broken + remove MediaThumbnailFormatter because it's broken » Default File & Image displays look broken: improve them
Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
Related issues: +#2889438: Delete media delivered icons on uninstall
StatusFileSize
new124.85 KB
new7.51 KB
new3.14 KB

Per #9 and #10, sounds like this needs more review. I had forgotten MediaThumbnailFormatter was intended for the thumbnail base field. I should've read the code.

The reason it looks as broken as it does for me is #2889438: Delete media delivered icons on uninstall — I only had no-thumbnail.png, I didn't have generic.png because of that! The correct screenshot is:

(Updated the IS to use this one.)

I may be missing the point (sorry if it's the case), but isn't the thumbnail a basefield of type image, and then, viewable by any formatter that can be applied to image fields?

Indeed. And guess what: nothing uses the media_thumbnail formatter! Not views.view.media (/admin/content/media) which is shown in #10, nor the default File & Image displays.

However, #3 and #4 are plain wrong: nothing was broken because of the MediaThumbnailFormatter! Removing that is out of scope here. Updated IS + title. Working on updated patch.

Sorry for the sloppiness on my side.

The patch is now only about improving the default entity view displays.

dawehner’s picture

Ah this makes sense now.

Indeed. And guess what: nothing uses the media_thumbnail formatter! Not views.view.media (/admin/content/media) which is shown in #10, nor the default File & Image displays.

Indeed, but maybe it should actually?

+++ b/core/modules/media/config/install/core.entity_view_display.media.file.default.yml
@@ -3,48 +3,22 @@ status: true
   field_media_file:
-    label: above
+    label: hidden

+++ b/core/modules/media/config/install/core.entity_view_display.media.image.default.yml
@@ -3,49 +3,25 @@ status: true
   field_media_image:
...
     label: hidden

Is there a reason we cannot go visually hidden? I assume it would be better accessibility wise to have the label still around.

wim leers’s picture

StatusFileSize
new1.34 KB
new3.16 KB

#12: I was contemplating that too :)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Site builder experience (SX)

I think this totally make sense.

One less thing site builders have to change to even make sort of a positive impact.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 2895382-13.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Reviewed & tested by the community

Retesting, re-RTBC.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Title: Default File & Image displays look broken: improve them » Hide label, thumbnail, etc. for default display of media file and image references
xjm’s picture

Issue summary: View changes
StatusFileSize
new88.82 KB
new93.95 KB
new79.89 KB
new96.49 KB

As I think @dawehner started to say in #9, please don't use words like "broken" and "useless". They create an unnecessarily negative tone and interfere with the progress of an issue.

Attaching screenshots of the configuration screen at Admin -> Structure -> Media types for the File and Image media types' entity displays, to illustrate the changes for the site builder.

In HEAD

File configuration:

Image configuration:

With the patch

File configuration:

Image configuration:

So I definitely agree with:

  • Hiding the "File" and "Image" labels visually, but keeping them as visually hidden for accessibility.
  • Removing display of the thumbnail for files, since the file plugin doesn't provide a meaningful thumbnail and the default thumbnail does not add information.

I'm less sure about:

  1. Removing the author and created fields. In the case of embedding the rendered media entity in a media field, they are probably not useful. But in the case of administering site media (i.e. viewing the media entity directly), they could be useful information, in the same way that the node author is useful information. I'm confused by:

    creation date, author seem of little relevance, since most media are not actually created by the user who uploaded it

    How is this the case? If they seem to be created by someone else, that would seem like a bug? I tested and it seems to report the correct user.

    Edit: I guess this means that the file itself isn't necessarily created by the user who uploaded it, e.g. a content editor didn't take the photo that they're adding to the article. However, I think it's also very common for users to upload files that they created themselves. And, regardless, it's useful information to know who put that image on your site or who submitted the file. So this doesn't seem like a reason one way or the other to me. I think it's more about what's most commonly useful to site builders so that they have less to configure.
     

  2. Removing display of the image thumbnail. (Note that the summary does not match the current patch. In the current patch, the image thumbnail is hidden and the default "medium" image style is displayed.) When Media is viewed directly, the site builder might want to see what the thumbnail will look like, and compare it to the full image. This is useful for e.g. an image gallery or user profile directory, where you might want to compare the thumbnail that will be used in a view to the style that will be displayed on the full page.

It probably still makes sense to go forward with those two changes as well, because the File and Image plugins are mainly intended as replacements for core file and image, and the 80% usecase is probably just displaying the normal file formatter and displaying a reasonably-sized version of the image. For creating advanced displays of the media, the site builder would probably be reconfiguring things anyway; the current display is not really well-suited to that usecase either. However, I did want to document the questions since I considered them.

Leaving at RTBC for the moment to think about it some more. The greatest advantage of doing this soon is probably that it makes #2831943: Use "rendered media" (not links) as default media field formatter; add modal to configure the used media view mode straightforward; using files and images in Media fields is probably much more common than viewing their entities directly.

xjm’s picture

Issue summary: View changes
larowlan’s picture

Yes, I agree that the 80% use case is the normal file/image formatter. On most client sites I've worked on access to /media/x or file/x in case of D7 is rare, and when clients do find themselves there, they find it confusing. They're much more likely to use /media/x/edit or file/x/edit than the full page view.

  • xjm committed 1da4fed on 8.5.x
    Issue #2895382 by Wim Leers, chr.fritsch, xjm, marcoscano, dawehner,...

  • xjm committed 2e2a8fb on 8.4.x
    Issue #2895382 by Wim Leers, chr.fritsch, xjm, marcoscano, dawehner,...
xjm’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Fixed

Thanks @larowlan. That's confirmation enough to overcome my waffling. Committed and pushed to 8.5.x. I also backported it to 8.4.x since it's a strategic initiative, etc. and we've still a full week before the beta deadline.

Status: Fixed » Closed (fixed)

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