New Global Built In Function

I wonder if you can help? I have a podcast and I have fallen out of love with Hugo (it’s such a confusing "£$%) and I’ve found Zola and made lots of progress in no time (sign of a good tool!). But really need to automate the creation of some file meta data. (I’ve currently got frontmatter [extra] size = 294884 … omg no please no for 250+ podcasts…)

I need to know the file size using a template function, of an MP3 asset on disk (and ideally the duration and a bunch of ID3 tag information there is a rust id3 lib for that here) but for now I would settle for just being able to get the file size in bytes of an asset on disk.

I had a quick look at GetImageMeta here to see if I could add a new global function to get file size myself…

I’ve never used Rust and its a bit beyond me.

But it looks like fs::meta on rust-lang org does exactly whats needed.

Looking at the structure of the code the lib.rs would need to be updated to link the function into the tera template.

With something like this in the docs:

get_file_metadata

Gets metadata for a file asset on disk. Today the only supported keys are size.
{% set meta = get_file_metadata(path="…") %} Our asset is {{ meta.size }} bytes.

I wonder if anyone could help me with this? or consider it for a future version release?

Thanks for reading this far :slight_smile:

Hi

The get_file_metadata might make sense but I don’t think it will go as far as you will need with the MP3 information for example. I’m probably going to wait to see if there are more people needing that before implementing it.

Thank for getting back to me. The mp3 info is only likely to be necessary for music sites and people who host podcast rss feeds. I don’t know how many of those use zola. There are quite a few of us podcasters. As I said file size would be a huge help initially. Thanks for considering it.