If you add you have code that does this:

function mymodule_file_load(array $files) {
  foreach (
$files as $file) {
$file->alt = 'Default alternate text for this image';

Then if that file is used in an image field, and the user manually provides an alterate text value in the field widget, that means that the node is loaded, the image field value's $item['alt'] gets overridden with $file->alt. Think the file entity properties should be merged, but not override any field value properties. It's a simple fix of re-ordering the array_merge() parameters in file_field_load().

#2 2066275-before.png355.6 KBbrantwynn
#2 2066275-after.png353.81 KBbrantwynn
#1 2066275-file-field-load-merge-order.patch513 bytesDave Reid
PASSED: [[SimpleTest]]: [MySQL] 40,396 pass(es).
[ View ]


Status:Active» Needs review
new513 bytes
PASSED: [[SimpleTest]]: [MySQL] 40,396 pass(es).
[ View ]

This does not need to be fixed in Drupal 8 because file fields set $item->entity as the file entity in that case, so there is no conflict between properties.

Status:Needs review» Reviewed & tested by the community
new353.81 KB
new355.6 KB

Tested this using the default 'Article' bundle with field_image. I added a new node with an image and entered alt text.

Before applying the patch, I was not seeing the any alt text on the rendered image on the page:

However, I was seeing the alt text I had entered in thefield_image_alt column in the field_data_field_image table in my db.

After applying the patch, I am now seeing the rendered alt text on the page:

This looks good to go.

Assigned:Dave Reid» Dries

Dries asked this to be assigned to him at MWDS.

Status:Reviewed & tested by the community» Fixed

Committed to 7.x. Thanks! :)

Assigned:Dries» Unassigned

Status:Fixed» Closed (fixed)

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

This seems to have reappeared in 7.24. The same patch, though now on line 189 fixes the problem.

It looks like this change is actually in the latest 7.x Git history, so it hasn't been lost. But because this is a "security release" only, 7.24 is identical to 7.23 (released August 7, 2013) other than the security fix. So everything is officially as it should be, but it's confusing to some users who have been waiting since August to have this fixed. The bottom line is, "wait for 7.25" (assuming it's not another security-only release).

Thank you for addressing this so promptly quicksketch. I was not aware that security releases did not include bug fixes. I'll be running a patched version of 7.24 for peace of mind until 7.25 lands.

I just had the same experience, so I'm glad to have been able to help. :)

Patch in #1 fixes all the things.

We had image galleries that utilised the title text for the caption, unfortunately Drupal decided to clobber 100% of this text (and the alt text) upon node_save(), meaning the content authors now have to manually recreate after this is patch released.

Wish this made it into 7.24. Data loss is never fun.

Also lost all image title and alt information with the update to Drupal 7.24 on several websites. This simple patch fixes it, but I despaired for a number of hours before finding it.

It's unfortunate that a normal (not just security) update has not been published since August 7th.

Here is a patch file with the update applied to line 189.


I too hope this gets amended in a Drupal 7.25 release.

Issue summary:View changes
Issue tags:+7.25 release notes

Added this issue to CHANGELOG.txt since it's a (minor) behavior/API change.

Title:file_field_load() overwites any field item properties with file entity properties(followup: tests) file_field_load() overwites any field item properties with file entity properties
Status:Closed (fixed)» Active

It's also a testable bug but was committed without tests.

Just verified that the core patch did get committed to 7.25 - Just wanted to thank you @Dave Reid