Hi

If you have a multiple files attached to node and you select that none of them are displayed, this function should unset un-displayed (none-displayed) items in $items array.

But it doesn't. Because of the position "$items[$id] = array_values($items[$id])" line. This line set indexes keys in new order for every item inside entities. Because of that some items are left out and are displayed on the page/node.

The line '$items[$id] = array_values($items[$id])' should go one "foreach" sentence up in hierarchy.

I think, that this line should be executed for each entities after items has bee processed.

Take care,
Damjan

Comments

damjan.cvetan’s picture

Title: Documentation problem with file_field_prepare_view » Problem with file_field_prepare_view
Component: documentation » field system
damjan.cvetan’s picture

Version: 7.x-dev » 7.0
damjan.cvetan’s picture

StatusFileSize
new1.05 KB

Sorry, wrong patch.

damjan.cvetan’s picture

Version: 7.0 » 7.x-dev
StatusFileSize
new576 bytes

The same in 7.x-dev.

catch’s picture

Component: field system » file.module
Status: Active » Needs work
Issue tags: -file field

You should roll the patch from the root of Drupal core, that way the test bot will be able to apply it.

damjan.cvetan’s picture

StatusFileSize
new550 bytes

Tnx for the advice. Is now ok?

damjan.cvetan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1041508_fix_file_field_prepare_view.patch, failed testing.

damjan.cvetan’s picture

Status: Needs work » Needs review
StatusFileSize
new684 bytes
dave reid’s picture

Status: Needs review » Closed (duplicate)
andrus9000’s picture

Hi, I'm not able to patch (probably because of my shared hosting plan), could you guide me through a manual file editing?
Thanks very much in advance!

damjan.cvetan’s picture

You just need to open file /modules/file/file.field.inc and make changes below

@@ -203,9 +203,9 @@ function file_field_prepare_view($entity
if (!file_field_displayed($item, $field)) {
unset($items[$id][$delta]);
}
- // Ensure consecutive deltas.
- $items[$id] = array_values($items[$id]);
}
+ // Ensure consecutive deltas.
+ $items[$id] = array_values($items[$id]);
}
}