Problem/Motivation

Background

With the following modules enabled on a clean build:

* Entity
* Media entity
* Media entity image
* Embed
* Entity Embed
* Entity Browser
* Ctools

And entity browser set up (otherwise successfully) using this tutorial:

https://www.webwash.net/manage-media-assets-drupal-8/

Attached to this image is a config sync folder that could be used to replicate the site with drush site-install --config-dir=...

Steps to repeat

With media bundles etc. in place as per the tutorial or the sync folder provided:

1. Upload an image (A) via media/add/image : title is configurable; file is stored on field_media_file.
2. Create content at node/add/page
3. Press rich-text entity embed button
4. Select the "Select" tab in the iframe
5. Embed image A, no caption included.
6. Select the "Upload" tab in the iframe
7. Upload an image (B) via the widget: title is set to the image's filename; file is stored on field_media_file.
8. Embed image B, no caption included.
9. View source.

What I see

* Image A is present with a title attribute
* Image B is present without a title attribute

Example (whitespace added for clarity):

<article class="embedded-entity">
  <img src="/sites/mediatest/files/2017-08/streptocarpus_katie.jpg"
    width="2048" height="1152" alt="Thumbnail" title="Added via media/add/image" typeof="foaf:Image" />
</article>
<article class="embedded-entity">
  <img src="/sites/mediatest/files/20969200_127909691170397_7471335914812211200_n.jpg"
    width="800" height="1000" alt="Thumbnail" typeof="foaf:Image" />
</article>

Editing image B and changing its media name to be something other than the filename makes no difference: the title attribute is still missing.

Furthermore:

* Both attached files look the same at admin/content/files
* Both media items look the same (as far as I can tell, but there could be - should be? - a database difference)
* The alt="Thumbnail" on both images is a separate issue for media_entity, I think. The difference between the two images is the problem.

This has accessibility implications: hence I've tagged it a11y and set the priority to "Major."

What I should see

* Both images should have title attributes.

Proposed resolution

* Diagnose why image media created via the Entity Browser upload widget is displaying differently
* Perhaps offer extra fields in the upload widget, so that the media name can be set (although editing that later makes no difference)

Remaining tasks

* Triage
* Other steps tbc.

User interface changes

tbc.

API changes

tbc.

Data model changes

tbc.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jp.stacey created an issue. See original summary.

jp.stacey’s picture

Issue summary: View changes

Note added to description:

This has accessibility implications: hence I've tagged it a11y and set the priority to "Major."

jp.stacey’s picture

Further investigation: it looks like thumbnail__title is being set during media/add/image, but not by the upload widget; although thumbnail__alt is always set:

mysql> SELECT mid, name, thumbnail__alt, thumbnail__title FROM media_field_data;
+-----+---------------------------+----------------+---------------------------+
| mid | name                      | thumbnail__alt | thumbnail__title          |
+-----+---------------------------+----------------+---------------------------+
|   1 | Added via media/add/image | Thumbnail      | Added via media/add/image |
|   2 | Test filename             | Thumbnail      | NULL                      |
+-----+---------------------------+----------------+---------------------------+
2 rows in set (0.00 sec)

(Unhelpfully for accessibility-impaired visitors, thumbnail__alt is always set to "Thumbnail": but that's a separate issue across all media_entity, I think!)

jp.stacey’s picture

Further information: the reason "Thumbnail" is set, but title isn't, probably arises from media_entity module's Media.php, around line 238 in ::preSave():

    $this->thumbnail->alt = t('Thumbnail');
    $this->thumbnail->title = $this->label();

So that at least explains why "Thumbnail" always gets set, but title doesn't unless there's a label during Media::preSave().

mgifford’s picture

Issue tags: -a11y +Accessibility

moving from the "a11y" tag to "accessibility".