The best time to register for DrupalCon Dublin is now. Earlybird discounts end July 29.
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
Some blockers:#1448124: Image dimensions should be available from file_load() for images, and not stored in field data
8.1.x material at this point
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?)
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.
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
Yes, but that's actually solveable now. widgets/formatters now have a method to only apply to a field type with certain configurations.. for example, we have taxonomy term specific entity reference formatters. The same would be possible for an image/file formatter although they'd be missing things the file field display/description.
So we could open an issue to make them available.
My point is that I think we've likely done as much as possible already, apart from some problems that already have or should have separate issues. And might not even need this issue anymore...
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 ?
Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.
Drupal is a registered trademark of Dries Buytaert.