The function file_view_multiple contains a bug that results in the items array being empty within template_preprocess_field thus nothing is shown. The issue is that the function file_view_multiple incorrectly places the file items in a subarray: "files" array rather than at the root of the build array. The function template_preprocess_field expects the renderable items to be located at the root of the renderable field build array not nested in a "files" array. This problem manifests itself when no video is seen on the node page. I think it is as simple as the below to fix.
Within the function file_view_multiple change this:
foreach ($files as $delta=>$file) {
$build['files'][$file->fid] = file_view($file, $view_mode, $langcode);
$build['files'][$file->fid]['#weight'] = $weight;
$weight++;
}
$build['files']['#sorted'] = TRUE;
to this
foreach ($files as $delta=>$file) {
$build[$file->fid] = file_view($file, $view_mode, $langcode);
$build[$file->fid]['#weight'] = $weight;
$weight++;
}
$build['#sorted'] = TRUE;
I'll submit a patch once I verify some more and have the time unless someone else does.
Comment | File | Size | Author |
---|---|---|---|
#6 | share.make_.yml | 2.54 KB | oddz |
Comments
Comment #1
oddz CreditAttribution: oddz commentedComment #2
AdamGerthel CreditAttribution: AdamGerthel at Odd Hill commentedI've tested your change but noticed some really strange stuff, and a lot of images stopped showing up.
Comment #3
oddz CreditAttribution: oddz commentedThat is unexpected because xdebug was explicitly used to step through the code section by section to get to this result. In looking at the function template_preprocess_field there is no way that the files array would be rendered with the existing implementtion.
Comment #4
Dave ReidThis would break the entity_view() callback that we use. See also core's node_view_multiple() - it puts all the rendered nodes inside $build['nodes']. I don't see a regression with the way file fields are rendered using a view mode. Maybe you are usinga custom template_preproces_field() override?
Comment #5
oddz CreditAttribution: oddz commentedI don't think so I stepped line by line through code using xdebug to get to that solution. I will have a more indepth look when I get time. For the time being that solution doesn't seem to have any ramifications for me. I'm running the latest d7 core. I can say for fact though that on my environment media isn't rendering without that modification.
Comment #6
oddz CreditAttribution: oddz commentedThis is the build file used which I ran into said issue.
Comment #7
Dave ReidI cannot reproduce this issue, and we cannot change the function's output as it wouldn't be backwards compatible.