Is there a way to display the file's size next to it in a View? This is for a File field in Drupal 8.

I tried the advice (for D7) here, but I received this error.

The handler for this item is broken or missing. The following details are available: Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.

I am not sure which module it means. When I go to the modules list, the only thing with "file" in it is the actual File field module, which is installed. I ran composer update earlier today, and the status report shows that everything is current.

I also thought I might be able to do this by adding a field or doing a field re-write. So I looked under the list of available fields to add to the View and didn't see anything about file size there.

  • Thought there already is a built-in field formatter for that. But maybe you have to provide your custom field formatter.
    – leymannx
    Jun 21, 2020 at 19:01
  • @leymannx I'm afraid I don't understand. Do File fields have formatters like the Date fields?
    – Jaime K
    Jun 21, 2020 at 23:22

2 Answers 2


Various file properties are available directly in Views if you're Views type is File.

Since your Views type is probably Content you have to add the Relationship for the file field in your content that references the file(s).

The File field inside a Content Type only stores the reference to the file ID, nothing else.

When you add the Relationship for the File field from the Content Category, new fields will become available in Views. I twill be called something like File (field_file:target_id). You can Require it if you only want to see results where that field isn't empty.

When you go to add a new field you will see File size available from the File Category.

  • Thank you. This was exactly what I needed. I see now that I didn't understand the post I linked to, but you pointed out what I missed. I just tried to upvote this, but this is a new account and I don't have enough reputation yet, so the system won't let me.
    – Jaime K
    Jun 21, 2020 at 22:45

You have different options:

  • create a pseudo field which markup is showing file size
  • preprocess the file field
  • relationship on view for file field and then you are able to place filesize field or in overridden markup

If you go with custom you can use (load file entity) function https://api.drupal.org/api/drupal/core%21includes%21common.inc/function/format_size/8.2.x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.