2023-08-25 19:09:50 +02:00
+++
2024-10-06 17:31:29 +02:00
description = "How to extend image effects"
2024-10-06 20:37:18 +02:00
frontmatter = ["imageEffects"]
options = ["imageEffects"]
2024-10-06 17:31:29 +02:00
title = "Custom Image Effects"
weight = 3
2023-08-25 19:09:50 +02:00
+++
2024-09-21 13:05:58 +02:00
The theme supports non-standard [image effects ](content/markdown#image-effects ).
2023-08-25 19:09:50 +02:00
2024-03-16 10:00:40 +01:00
| Name | Description |
| -------- | ----------------------------------------------------------------- |
| border | Draws a light thin border around the image |
| lazy | Lets the image be lazy loaded |
| lightbox | The image will be clickable to show it enlarged |
| shadow | Draws a shadow around the image to make it appear hovered/glowing |
2024-10-06 20:37:18 +02:00
As [described ](content/markdown#image-effects ), you can add this to the URL query parameter, but this may be cumbersome to be done consistently for the whole page. Instead, you can configure the defaults in your `hugo.toml` as well as overriding these default in the pages frontmatter.
2023-08-25 19:09:50 +02:00
2024-10-06 20:37:18 +02:00
Explicitly set URL query parameter will override the defaults in effect for a page or your site.
2023-08-25 19:09:50 +02:00
2024-10-06 20:37:18 +02:00
Without any settings in your `hugo.toml` `imageEffects` defaults to
2023-08-25 19:09:50 +02:00
2024-03-02 11:04:52 +01:00
{{< multiconfig file = hugo > }}
2023-08-25 19:09:50 +02:00
[params]
[params.imageEffects]
border = false
2024-03-16 10:00:40 +01:00
lazy = true
2023-08-25 19:09:50 +02:00
lightbox = true
shadow = false
2024-03-02 11:04:52 +01:00
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
2024-10-06 20:37:18 +02:00
{{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} This can be overridden in a pages front matter by eg.
2023-08-25 19:09:50 +02:00
2024-03-02 11:04:52 +01:00
{{< multiconfig fm = true > }}
2023-08-25 19:09:50 +02:00
[imageEffects]
border = true
2024-03-02 11:04:52 +01:00
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
Or by explicitly override settings by URL query parameter
2024-03-02 11:04:52 +01:00
````md {title="URL"}
2023-08-25 19:09:50 +02:00

````
The settings applied to the above image would be
2024-03-02 11:04:52 +01:00
{{< multiconfig > }}
border = true
2024-03-16 10:00:40 +01:00
lazy = true
2024-03-02 11:04:52 +01:00
lightbox = false
shadow = false
bg-white = true
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
This ends up in the following HTML where the parameter are converted to CSS classes.
````html {title="HTML"}
2024-03-16 10:00:40 +01:00
< img src = "https://octodex.github.com/images/minion.png?lightbox=false&bg-white=true" loading = "lazy" alt = "Minion" class = "bg-white border lazy nolightbox noshadow" >
2023-08-25 19:09:50 +02:00
````
## Extending
2024-10-06 20:37:18 +02:00
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} As you can see in the above example, the `bg-white` parameter is not initially supported in the themes default settings. The theme allows you to define arbitrary parameter by just adding them to the URL query parameter or set them in your page's frontmatter or `hugo.toml` .
{{< multiconfig file = hugo > }}
[params]
[params.imageEffects]
bg-white = true
border = false
lazy = true
lightbox = true
shadow = false
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
{{% notice note %}}
2024-10-06 20:37:18 +02:00
If no extended parameter like `bg-white` in the example is set on the URL, a `class="nobg-white"` in the HTML will only be generated if a default value was set in the page's frontmatter or `hugo.toml` .
2023-08-25 19:09:50 +02:00
{{% /notice %}}