Closed (fixed)
Project:
Bartik
Version:
1.1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Feb 2026 at 16:47 UTC
Updated:
1 May 2026 at 18:45 UTC
Jump to comment: Most recent
If an image widget's file has no size returned from $file->getSize(), a fatal error occurs, causing a "white screen of death".
In Drupal core, they added an IF statement to only show the file size span if the size exists. See #3117430: file-link template should not always display file_size. Bartik should do the same in bartik_preprocess_image_widget()
function bartik_preprocess_image_widget(&$variables) {
if (!empty($variables['element']['fids']['#value'])) {
$file = reset($variables['element']['#files']);
if ($size = $file->getSize()) {
$variables['data']["file_{$file->id()}"]['filename']['#suffix'] = ' <span class="file-size">(' . ByteSizeMarkup::create($size) . ')</span> ';
}
}
}
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
solideogloria commentedComment #3
solideogloria commentedComment #4
solideogloria commentedComment #7
solideogloria commentedLooks good to me.
Comment #8
liam morlandI have adjusted it to allow for zero size.
Comment #9
solideogloria commentedNice. I didn't think of that.
Comment #11
liam morlandThanks!