Closed (fixed)
Project:
Drupal core
Version:
11.3.x-dev
Component:
file.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Oct 2024 at 15:38 UTC
Updated:
4 Dec 2025 at 11:49 UTC
Jump to comment: Most recent

Comments
Comment #2
marc.bauDefect is in core\modules\file\src\Plugin\Field\FieldFormatter\TableFormatter.php that is using '#theme' => 'file_link'. The file-link.html.twig template adds the file size. I guess this requires a file_link theme suggestion without file size as the file_link template can be used in other situations where this file size makes sense.
Comment #3
marc.bauComment #4
cilefen commentedIndeed it does.
Comment #7
mfbWhile fixing this issue w/ file module, it seemed like a good time to also fix a related issue with Claro theme, which, unlike the default file link template, was missing the logic to not show the file size if it's empty.
Comment #8
smustgrave commentedProbably would be good to keep the claro changes separate to not delay the fix here.
But we should probably have test coverage
Comment #9
mfbComment #10
smustgrave commentedCan the proposed solution be cleaned up some as it appears we are adding a new variable key and that's not clear in the IS.
Also why set core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php to FALSE? Only concern is if this could be a breaking change for someones existing site.
Comment #11
mfbDo we need to add a code comment in TableFormatter where we set #with_size to FALSE?
Comment #12
smustgrave commentedComment always could help
Comment #13
smustgrave commentedThanks for adding the comment.
Ran the test-only job here https://git.drupalcode.org/issue/drupal-3482024/-/jobs/6705066
Rest of the changes appear to be inline, was wondering if we add to update any templates docs for the new key 'with_size' but hoping we don't need that.
Comment #14
mfbI don't see a need to update the template docs because the with_size variable isn't used there. (It /could/ have been used there, if we moved the logic from the preprocess function into the template, but I didn't put the logic there to minimize the need for updating templates.) I assume templates don't need to exhaustively document all possible variables.
Comment #15
catchReviewed this a couple of times and went around in circles on documenting vs not but overall agree with @mfb in #14 - we're not using it in the default template and don't particularly intend anyone else to use it, so documenting could be more confusing than not.
Committed/pushed to 11.x and cherry-picked to 11.3.x, thanks!