Problem/Motivation

I tested the upgrade of one of my first Drupal 8 projects to 8.5.0. Because of its age the site is using file_entity.
After the upgrade I saw, that all image thumbnails in the node forms showed Drupal's internal file uri public://images/test.jpg instead of the rendered thumbnail image. While investigating I saw, that the Field Formatter Widget for "URI" changed at /admin/structure/file-types/manage/image/edit/display/thumbnail.
Instead of "File URI", "File Image", "Plain text" only "File URI" is available. That explains what I see in the node form. It seems that field type changed, so that the FieldFormatter is not matching anymore.

I changed

@FieldFormatter(
 *   id = "file_image",
 *   label = @Translation("File Image"),
 *   field_types = {
 *     "uri"
 *   }
 * )

to

@FieldFormatter(
 *   id = "file_image",
 *   label = @Translation("File Image"),
 *   field_types = {
 *     "file_uri"
 *   }
 * )

And the FileImageFormatter came back again and worked as designated.

I haven't followed the changes that went into in 8.5.0, but it might be #2825487: Fix normalization of File entities: file entities should expose the file URL as a computed property on the 'uri' base field or one of its related issues, that cause the trouble.

Screenshot from Project Drupal 8.4.5:
8.4.5

Screenshot from fresh Drupal 8.5.0 install and enabled file_entity
8.4.5

The issue is visible in file_entity 8.x-2.x-dev and 8.x-2.0-beta4.

Do you experience the same?

Proposed resolution

  • Find out what in core caused the issue
  • Add new field type to the FieldFormatter annotation to make it available in Drupal 8.5.0

Comments

szeidler created an issue. See original summary.

szeidler’s picture

Status: Active » Needs review
StatusFileSize
new1020 bytes

The attached patch (for 8.x-2.x-dev) makes the FileImageFormatter and FileImageResponsiveFormatter available in Drupal 8.5.0 by adding the file_uri file type in addition to make it work with Drupal 8.4 and 8.5.

webflo’s picture

I have the same issue, thanks for the patch.

jonmcl’s picture

Am I missing something or is this a major change that seems to be missing clear change record? The linked issue, and CR, seem to be all about the JSON API, but this is a field type change? I would think this would break a few things.

Thank you for the patch! Hopefully this it is all that is needed.

Huelfe’s picture

Patch works fine for me. Thank you! :)

weseze’s picture

Seems like a major regression in D8.5 when using file_entity...

The patch fixes the issue!

Attached is a patch against latest stable '8.x-2.0-beta4 released 10 August 2017' which doesn't have the responsive formatter yet.

  • joseph.olstad committed 5401a99 on 8.x-2.x authored by weseze
    Issue #2951451 by szeidler, weseze: FileImageFormatter not available...
joseph.olstad’s picture

Status: Needs review » Fixed

fixed in dev branch 8.x-2.x-dev

szeidler’s picture

Status: Fixed » Needs review
StatusFileSize
new506 bytes

Thanks for the prompt commit.
Sorry for reopening the issue, but I think we should fix for the Responsive Image Formatter (from dev) as well, like I did in patch #2.

I created a new patch based on the current dev, that is just adding it.

webflo’s picture

Status: Needs review » Reviewed & tested by the community

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

will this break backwards compatibility?

esolitos’s picture

I did test the patch on 8.4 and seems to be working fine.
Haven't done a deep test, just applied and manually tested a few use cases: No error, notices or anything visibly broken.

Status: Fixed » Closed (fixed)

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