CMS Development

Anton
名誉エキスパート

Get fielsize from filemanager into module

解決

Hey fellow community members, 

I'm building a module for our ressources page an would like to display the filesize of each file which is uploaded to the filemanager in a module which gets all the other information from a HubDB. The current workaround is a textfield where the colleague who will manage the HubDB can input a number and then it is displayed with the |filesize and a multiplier filter in the module. But since this isn't very convinient convinient my idea was to automate this step.

 

Anybody an idea?

 

 

best, 

Anton

Anton Bujanowski Signature
0 いいね!
1件の承認済みベストアンサー
stefen
解決策
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

Get fielsize from filemanager into module

解決

@Anton You can find that by using the file_by_id HubL function like so:

{% set file = file_by_id(123) %} 
{{ file.size }}
<!-- this will print the size in bytes -->

However, the issue I've run into with this is that it's not very easy to get a file ID to use with this function since it's not really a user facing ID or a field available in custom modules. If you find a way to surface this ID easily I'd love to know.

Stefen Phelps, Community Champion, Kelp Web Developer

元の投稿で解決策を見る

2件の返信
stefen
解決策
キーアドバイザー | Solutions Partner
キーアドバイザー | Solutions Partner

Get fielsize from filemanager into module

解決

@Anton You can find that by using the file_by_id HubL function like so:

{% set file = file_by_id(123) %} 
{{ file.size }}
<!-- this will print the size in bytes -->

However, the issue I've run into with this is that it's not very easy to get a file ID to use with this function since it's not really a user facing ID or a field available in custom modules. If you find a way to surface this ID easily I'd love to know.

Stefen Phelps, Community Champion, Kelp Web Developer
Anton
名誉エキスパート

Get fielsize from filemanager into module

解決

Man, I feel kinda dumb right now 😀

Thank you very much. Works flawlessly with HubDB

 

Yeah, you're right... It's a bummer that if you use the "image" function in a custom module you only get the url and the sizes... If I come up with something I will keep you in touch.

 

Maybe with the new files API(when it's gonna be availibe) you will be able to get the ID by file url

 

best, 

Anton

 

Anton Bujanowski Signature