Template function to fetch remote file

I’d like to see a function to use in templates which fetches a remote file.

In my case, I would like to fetch remote thumbnails for YouTube videos. But I can imagine that this is useful as well for other cases

Semantics

This function could look like this:

fetch_raw(url="...") -> Url
  • This is similar to load_data , in the sense that it fetches remote data
  • This is similar to resize_image , in the sense that the command returns an URL for the locally stored file (to static/processed_images ) in this case.

Modifying the existing resize_image function to support a remote url would be an option for me as well.

What are the thoughts on this? Could this be implemented?

Related GitHub issue: https://github.com/getzola/zola/issues/738

I don’t think that would scale, not everything you want to fetch is going to be an image that you want to resize and even if it is, you might not want to resize it.

Do you know how that’s handled in Hugo/Jekyll etc?

Yes, a new function for this would be better. Though, the option to resize it as well would be nice, and I don’t think it would be chainable in the current state.

Not sure about Hugo or other static engines. I’ll take a look into it.