Cadey is coffee
<Cadey> Hello! Thank you for visiting my website. You seem to be using an ad-blocker. I understand why you do this, but I'd really appreciate if it you would turn it off for my website. These ads help pay for running the website and are done by Ethical Ads. I do not receive detailed analytics on the ads and from what I understand neither does Ethical Ads. If you don't want to disable your ad blocker, please consider donating on Patreon or sending some extra cash to xeiaso.eth or 0xeA223Ca8968Ca59e0Bc79Ba331c2F6f636A3fB82. It helps fund the website's hosting bills and pay for the expensive technical editor that I use for my longer articles. Thanks and be well!

Site Update: Hero Images

Read time in minutes: 5

For a while I've been wondering how I can add dramatic flair to my website with so-called "hero images". These images are tools that let you describe the mood a website wants to evoke. I've been unsure how to best implement these on my website for a while, but with the advent of MidJourney and other image generation APIs/algorithms I think I have found a way to create these without too much effort on my part and the results are pretty fantastic:

hero image secret-to-life
Image generated by MidJourney -- the secret to life, the universe and everything, concept art

I have generated a bunch of other images that I'm going to use for my other posts. I'll give out a desktop wallpaper sized version of each of these images on my Patreon.

Under the hood this is powered by lol_html and Maud. The magic is mostly contained in a function that generates a <figure> HTML element (which I just learned exists today). I use a function that looks like this for generating the <xeblog-hero> snippets:

pub fn xeblog_hero(file: String, prompt: Option<String>) -> Markup {
    html! {
        figure.hero style="margin:0" {
            picture style="margin:0" {
                source type="image/avif" srcset={"" (file) ".avif"};
                source type="image/webp" srcset={"" (file) ".webp"};
                img style="padding:0" alt={"hero image " (file)} src={"" (file) "-smol.png"};
            figcaption { "Image generated by MidJourney" @if let Some(prompt) = prompt { " -- " (prompt) } }

I have it wired up with lol_html like this:

lol_html::element!("xeblog-hero", |el| {
    let file = el.get_attribute("file").expect("wanted xeblog-hero to contain file");
    el.replace(&crate::tmpl::xeblog_hero(file, el.get_attribute("prompt")).0, ContentType::Html);

The result is that I can declare hero images with HTML fragments like this:

<xeblog-hero file="miku-dark-souls" prompt="hatsune miku, elden ring, dark souls, concept art, crowbar"></xeblog-hero>

And I get this:

hero image miku-dark-souls
Image generated by MidJourney -- hatsune miku, elden ring, dark souls, concept art, crowbar

Mara is hacker
<Mara> This is powered by the <figure> tag, which is a new discovery to us. This is probably one of the most useful tags we never knew about and removed the need to write a bunch of annoying CSS and HTML.

The webp and AVIF versions of the hero images have a higher resolution version so that it looks nicer on retina screens. However, the png versions of these are locked to a resolution of 800x356 pixels because I was unable to crush them below a size of half a megabyte at full resolution. Realistically, this should only affect older browsers on slower hardware, so I don't expect this to have too much impact on most users.

Cadey is coffee
<Cadey> If you don't want to see these hero images, you can remove them with a userstyle like this:
figure.hero {
    display: none;

I'm likely going to convert over most of my website templates to use Maud. I'm very happy with it and I think it is incredibly useful to express your HTML in Rust instead of something that has to be compiled to Rust. In practice it reminds me of the Nim library emerald, which lets you write HTML using Nim functions similar to how you use Maud.

Here's a few more examples of hero images I have generated:

hero image the-forbidden-shape
Image generated by MidJourney -- the forbidden shape

hero image great-wave-cyberpunk
Image generated by MidJourney -- the great wave off of kanagawa, cyberpunk, hanzi inscription

Normally I will only have one image per post and it will usually be after the introduction paragraph. The prompt will usually be related to the article topic, but sometimes I will take artistic liberty. If you have suggestions for prompts, please contact me with those ideas.

I hope these updates on how I've been messing with my site are interesting. I'm trying to capture the spirit of how I'm implementing these changes as well as details of how everything fits together.

This article was posted on M06 08 2022. Facts and circumstances may have changed since publication. Please contact me before jumping to conclusions if something seems wrong or unclear.

Series: site-update

This post was not WebMentioned yet. You could be the first!

The art for Mara was drawn by Selicre.

The art for Cadey was drawn by ArtZora Studios.

Some of the art for Aoi was drawn by @Sandra_Thomas01.