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?
I have a use case here as well. I’ve had a need to enrich taxonomies and taxonomy terms with extra metadata and content. Currently, there is no easy way to do that, that I know of, so I abuse the fact that section named the same as a taxonomy ends up being overridden by the taxonomy when rendered, but the section and it’s pages still seems to be loaded/processed. So, if I have a taxonomy “collection”, and create a section named “collection”, the section and its pages won’t be rendered, but the taxonomy will.
I then use method similar to what @welpo does. In the taxonomy_list.html template, I check if a section with taxonomy.name exists, and if it does, I set section variable to result of get_section. I do the similar in taxonomy_single.html for each term, setting page variable instead.
The overall result is that I can selectively create sections and pages for taxonomies and terms that I want to enrich.