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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm created an issue. See original summary.

tkoleary’s picture

Issue tags: +Usability, +sprint
yoroy’s picture

slashrsm’s picture

It would IMO make sense to implement this based on the look&feel proposed in that issue.

seanB’s picture

Assigned: Unassigned » seanB
seanB’s picture

The 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.

pguillard’s picture

Issue summary: View changes
seanB’s picture

Probably best to wait with this until #2831940: Create file field widget on top of media entity is done.

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

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

phenaproxima’s picture

Status: Active » Postponed
naveenvalecha’s picture

Status: Postponed » Active

This issue has landed #2831937: Add "Image" MediaSource plugin and its unblocked now.

//Naveen

seanB’s picture

Wim Leers’s picture

Wim Leers’s picture

Title: Re-create Image field widget on top of media entity » [PP-1] Re-create Image field widget on top of media entity

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.

chr.fritsch’s picture

Component: file system » media system
bdimaggio’s picture

Assigned: seanB » bdimaggio
Issue tags: +Media Initiative
FileSize
5.6 KB

Adding 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.

bdimaggio’s picture

FileSize
3.07 KB

Improvement 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.

Berdir’s picture

I 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.

bdimaggio’s picture

@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 :)

Berdir’s picture

Sure, 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.

bdimaggio’s picture

FileSize
13.77 KB
10.83 KB

@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.

mondrake’s picture

Please 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.

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

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

Lukas von Blarer’s picture

Status: Postponed » Active

Since #2831940: Create file field widget on top of media entity is marked as wont fix, can we proceed with this?

phenaproxima’s picture

Status: Active » Closed (outdated)

We 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.

supermoos’s picture

#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 :-)