- 🇮🇳India krunalunadkat Pune
Hi @marcjana_84,
You can try using below solution,
1) Add this in .theme file in custom sub theme
<?php function HOOK_preprocess_file_link(&$variables) { if (isset($variables['file'])) { $variables['fileLinkDisplay'] = [ 'fileSize' => $variables['file'] ->getSize(), 'fileSizeFormatted' => format_size($variables['file'] ->getSize()), ]; } } ?>
2) Add this to custom sub theme
-> themes/custom/THEME_NAME/templates/field/file-link.html.twig{{ fileLinkDisplay.fileSize }} and {{ fileLinkDisplay.fileSizeFormatted }} will be available in your template. In twig file we can use as per below:- <span{{ attributes }}>{{ icon }} {{ link }} {{ fileLinkDisplay.fileSize }} {{ fileLinkDisplay.fileSizeFormatted }}</span>
Thanks
- Status changed to Needs review
over 1 year ago 10:42am 31 May 2023 - Status changed to Closed: outdated
about 1 year ago 3:31pm 23 September 2023