My use case is that I want to have a shortcode to create a <picture> element, but I want to only insert code for files that already exist (the rules for when I use webp or avif are not so easy to express in a static generator and I prefer to handle them separately).
get_file_metadata kind of works as a proxy, but avif support is flaky and I actually don’t care about the metadata, so only checking for the file would be more efficient.
Probably it is a very obscure use-case. Sadly, AVIF support is broken in the image crate that zola uses to read the metadata, but I’ll try look into collaborating with that.
I have a use case: I’m trying to set up a default header image for pages (that ends up in my open_graph previews). If the page or section has an image with the same path but .png|.jpg (components + some string concat is the best I’ve found for now. File search with the ability to either ignore extensions or give multiple options would be even better) get_url it, otherwise use the site default. Really I’d probably set page > section > config as fallbacks.
A basic error catching filter/ability to tell get_url to do warning only on this specific call only might be a broader category of thing that could be useful and would also cover this. I’ll probably do the load_data hack for now, but it’ll definitely make my template/shortcode a bit messier and do unnecessary processing.
ETA:
I guess I’ll make a macro to abstract that at least. Hmm, for images the get_image_metadata also accepts a required parameter, so maybe I grab that for making it not entirely an otherwise useless check. I guess if get_url had that param it’s make the whole issue mostly moot?