Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In some programatic changes that I was adding to a module of our own were unable to load the display so that the ->status attribute could be set.
I traced this down to a condition where any database that hasn't had the admin form for the file display configuration set up would not be able to call that function and yield a valid response.
Once the form is submitted the file_displays_load and file_display_save calls both work.
Comments
Comment #1
tahiche CreditAttribution: tahiche commentedHi,
If I understand correctly, I faced a similar issue where I had defined "hook_file_default_displays()" in my custom module to create a file type and have the right displays. My "file_default_displays()" function I got after exporting a feature and copying the result, with all the formats and settings for my file type.
Like you point out, and I don´t know if it´s the same scenario, these default displays are not recorded to database but read from that file until you save the display form (for each view mode).
Based on the issue Default file entities are not exportable by features regarding the default types not being saved to DDBB and thus not exportable, I´m saving these defaults on module enabling (you can do it on install too, i guess).
Something like this...