Problem/Motivation
When #2831274: Bring Media entity module to core as Media module lands we'll have new entity type for multi-media assets and after #2831937: Add "Image" MediaSource plugin we'll have support for local images. At that point we'll be able to create image media entities through stand-alone entity forms. This can be useful, but it is not the primary way content creators create media.
It is far better to allow them to do this from the content creation context. This is currently the case with image fields.
Proposed resolution
Create (or extend existing one) image field widget to be able to work with entity reference fields that reference media entities. Replicate look & feel of the existing image field. Also keep support for alt/title and save them as field values on the media entity.
Comment | File | Size | Author |
---|---|---|---|
#22 | interdiff-17-22.txt | 10.83 KB | bdimaggio |
#22 | 2831941-22.patch | 13.77 KB | bdimaggio |
#18 | 2831941-18.patch | 3.07 KB | bdimaggio |
#17 | 2831941-17.patch | 5.6 KB | bdimaggio |
Comments
Comment #2
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #3
yoroy CreditAttribution: yoroy at Roy Scholten commentedHow might this impact #2113931: File Field design update: Upload field. ?
Comment #4
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedIt would IMO make sense to implement this based on the look&feel proposed in that issue.
Comment #5
seanBComment #6
seanBThe new image widget design is here: https://www.drupal.org/node/2115469
About that, we can't implement the exact same field widget as core currently does. The alt text will be a problem since this is stored globally in media entities.
For this first widget it is probably best to just display the global alt text. We can discuss the best way to fix the 'alt text per instance' issue in a follow up.
Comment #7
pguillard CreditAttribution: pguillard commentedComment #8
seanBProbably best to wait with this until #2831940: Create file field widget on top of media entity is done.
Comment #10
phenaproximaAs per the roadmap (#2825215: Media initiative: Roadmap), this is postponed on #2831937: Add "Image" MediaSource plugin.
Comment #11
naveenvalechaThis issue has landed #2831937: Add "Image" MediaSource plugin and its unblocked now.
//Naveen
Comment #12
seanBI think this is still blocked on #2831940: Create file field widget on top of media entity
Comment #13
Wim LeersOkay, postponed on #2831940: Create file field widget on top of media entity.
Comment #14
Wim LeersComment #16
chr.fritschComment #17
bdimaggioAdding MediaImageWidget based on the work @marcoscano and I have done on #2831940: Create file field widget on top of media entity.
In order to test this patch, please apply #2831940-119: Create file field widget on top of media entity.
Comment #18
bdimaggioImprovement on yesterday's work that handles the (admittedly unlikely) situation where a site builder sets an image media entity's source image field to require "alt" and/or "title". See required complementary change in #2831940-120: Create file field widget on top of media entity.
Comment #19
BerdirI don't think that's unlikely at all actually, isn't the alt field being required the default setting? And if it's not for image bundles then it probably should be, because that was an explicit decision that was made to ensure good accessibility.
Comment #20
bdimaggio@berdir, good points. My comment came off as more dismissive of the alt field's importance than I meant it to. I think I've been hyper-focused on getting the whole Media(File|Image)Widget setup working for the 80% use case, and lost sight of accessibility to some extent. In my defense, I am ensuring that the alt field works :)
Comment #21
BerdirSure, I just meant to underline that supporting that is important because it *should* be the 80%/default use case and if it's not that now then we should have a separate issue to change that.
Did not mean to critize you (or anyone else) in any way.
Comment #22
bdimaggio@berdir no offense taken! It's absolutely helpful feedback.
Also, I just cleaned up the code a bit and added some testing. This patch includes the work from #18.
Comment #23
mondrakePlease note that #2377747: Incorrect node create validation error when an invalid image is attached to a field has added an additional validation to the ImageWidget (i.e. checking that the image file is valid). Would that need to be ported here too.
Comment #25
mondrakeSAme as #23, but for #1014816: Allow image fields to use any extensions the current image toolkit supports (instead of hard-coding jpg, png and gif only).
Comment #27
Lukas von BlarerSince #2831940: Create file field widget on top of media entity is marked as wont fix, can we proceed with this?
Comment #28
phenaproximaWe don't need to! :) The experimental Media Library module went into Drupal 8.6 and provides this functionality. I think we can close this issue as outdated.
Comment #29
supermoos CreditAttribution: supermoos commented#28, I don't see that Media Library 8.6 supports editing alt / title on the node edit page? "Replicate look & feel of the existing image field. Also keep support for alt/title and save them as field values on the media entity." so probably best not to close? Or am I missing something :-)