Follow-up on #1801304: Add Entity reference field
File and Image are actually references for an entity, but we a fancy widget. We might consider converting those field types to leverage Entity-reference.

See yched's comment

Comments

Dave Reid’s picture

Dave Reid’s picture

Issue tags:+Media Initiative
Dave Reid’s picture

Title:Meta: Replace File/ Image field types with Entity-reference» Replace File and Image field types with Entity-reference
Version:8.0.x-dev» 8.1.x-dev
Category:Task» Feature request
Issue summary:View changes

8.1.x material at this point

Berdir’s picture

file/image actually extend the entity reference field type.

And as long as the have additional properties that they need to store, that'll stay like this. I'm fairly sure that continue to be like that at least for 8.x and not something that can be changed in 8.* as it would be major API and data change. Not sure if that's even the goal (some things like width/height, definitely but things like the display flag of file fields still makes perfect sense?)

Dave Reid’s picture

Width and height should be moved to the file entity object, and not stored in the field data: #1448124: Image dimensions should be available from file_load() for images, and not stored in field data.

The other problem becomes if I reference files using an entity reference field, I cannot use any image or field formatters. There's not enough sharing between the three field types.

Berdir’s picture

Yes, as I said, width/height should definitely move away but I guess not all the other properties.

The other problem becomes if I reference files using an entity reference field, I cannot use any image or field formatters. There's not enough sharing between the three field types

yched’s picture

Agreed with what @Berdir said :

- since this issue was opened, a lot of progress was made on unifying the things that can be (file & image classes extend e_r classes, formatters extend the same base class...)

- but they need to stay separate field types since they have additional data and behavior, as demonstrated by the specific code that still exists in the respective Item and ItemList classes.

What might be discussed IMO is : should we reduce the UI confusion by hiding File entity in the list of entity types referenceable by a plain e_r field ? Is there a use case for referencing a file through an e_r field rather than through the native File / Image fields ?