Closed (fixed)
Project:
Drupal core
Version:
8.5.x-dev
Component:
media system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Jan 2018 at 15:27 UTC
Updated:
20 Jan 2018 at 21:39 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
balsamaComment #3
balsamaHere's a patch that just sets the default view mode to orginal image. So following the same steps as in the video will now result in this:

Comment #4
marcoscanoI believe we should adjust
\Drupal\Tests\media\FunctionalJavascript\MediaDisplayTest::testMediaDisplay()as well, but let's see what the testbot saysComment #6
balsamaUpdated the patch to include changes to MediaDisplayTest. I'm not sure how to assert that it's the original image though (they used to assert img.image-style-medium - original images don't get any classes added). We could assert that there are no classes, but that seems brittle.
Comment #7
marcoscanoLooks good to me, just a minor remark:
If we are not checking the
imgtag, then this last assert is redundant to the previous one. Maybe we can assert that.field--name-field-related-media article.media--type-image imgexists, without specifying any class?Comment #8
phenaproximaWe shouldn't remove this line; just change it to $assert_session->elementExists('css', 'img', $media_item);
Also, we could assert the original image (albeit not perfectly), by getting the 'class' attribute, splitting it by whitespace, and asserting that none of the classes start with
image-style-.Comment #9
berdirMakes sense, although it is IMHO a bad idea for an actual site to ever use original image, you never know what your users are uploading, might be huge 5MB pictures. But lets make media and normal image fields consistent and then we can think about adding something like a HD image style that would be used by default to standard?
About the test, we might also be able to assert the actual src attribute of the image?
In paragraphs test, we have something like this, except we'd want to use a getAtribute() on the image element that we load with elementExists():
Comment #10
balsamaAdded the assertion that the image exists back in (comment #8) and assert that the actual src attribute doesn't point to an image derivative (comment #9).
Comment #11
phenaproximaI think this looks right.
Comment #13
xjmAh, much better!
I tested this manually and confirmed Media image fields now behave the same way as image fields do by default.
I was surprised by file_url_transform_relative() here, but I couldn't come up with any specific concern. So seems okay.
Committed to 8.5.x. Thanks!
Comment #14
xjm