2023-08-25 17:09:50 +00:00
+++
2024-10-12 17:28:28 +00:00
categories = ["explanation", "howto"]
2024-10-06 15:31:29 +00:00
description = "How to extend image effects"
2024-10-06 18:37:18 +00:00
options = ["imageEffects"]
2024-10-08 20:28:16 +00:00
title = "Image Effects"
2024-10-06 15:31:29 +00:00
weight = 3
2023-08-25 17:09:50 +00:00
+++
2024-10-11 20:40:10 +00:00
This page shows you, how to configure custom [image effects ](authoring/markdown#image-effects ) on top of existing ones.
2023-08-25 17:09:50 +00:00
2024-10-12 16:37:59 +00:00
This setting can also [be overridden by your front matter ](authoring/imageeffects ).
2024-03-16 09:00:40 +00:00
2024-10-07 13:30:53 +00:00
If you don't configure anything in your `hugo.toml` , the image effects default to
2023-08-25 17:09:50 +00:00
2024-10-11 14:27:13 +00:00
## Default Values
2024-10-07 13:30:53 +00:00
{{< multiconfig > }}
2024-10-07 20:18:49 +00:00
[imageEffects]
border = false
lazy = true
lightbox = true
shadow = false
2024-03-02 10:04:52 +00:00
{{< / multiconfig > }}
2023-08-25 17:09:50 +00:00
2024-10-11 14:27:13 +00:00
## Configuration
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} You can change these settings in your `hugo.toml` and add arbitrary custom effects as boolean values (like `bg-white` in the below snippet).
2023-08-25 17:09:50 +00:00
2024-10-07 13:30:53 +00:00
{{< multiconfig file = hugo > }}
[params]
[params.imageEffects]
2024-10-11 14:27:13 +00:00
bg-white = true
2024-10-07 13:30:53 +00:00
border = true
lazy = false
2024-03-02 10:04:52 +00:00
{{< / multiconfig > }}
2023-08-25 17:09:50 +00:00
2024-10-07 13:30:53 +00:00
This would result in
2023-08-25 17:09:50 +00:00
2024-10-07 13:30:53 +00:00
{{< multiconfig > }}
2024-10-07 20:18:49 +00:00
[imageEffects]
bg-white = true
border = true
lazy = false
lightbox = true
shadow = false
2024-10-06 18:37:18 +00:00
{{< / multiconfig > }}
2023-08-25 17:09:50 +00:00
2024-10-07 13:30:53 +00:00
### Example
2024-10-11 14:27:13 +00:00
With this configuration in effect, the following URL
2024-10-07 20:18:49 +00:00
````markdown {title="Markdown"}
2024-10-07 13:30:53 +00:00
![Minion ](https://octodex.github.com/images/minion.png )
````
2024-10-11 14:27:13 +00:00
would result in
2024-10-07 13:30:53 +00:00
2024-10-07 20:18:49 +00:00
````html {title="HTML"}
2024-10-07 13:30:53 +00:00
< img src = "https://octodex.github.com/images/minion.png" loading = "lazy" alt = "Minion" class = "bg-white border nolazy lightbox noshadow" >
````
2024-10-11 14:27:13 +00:00
## Styling Effects
If the resulting effect value is
- `true` : add a class with the effect's name
- `false` : add a class with the effect's name and a "no" prefix
Styles for default effects are contained in the theme. Add styles for your custom effects to `layouts/partials/content-header.html` .
2024-10-07 13:30:53 +00:00
2024-10-11 14:27:13 +00:00
For the above example you could add styles for both boolean cases:
2024-10-07 13:30:53 +00:00
2024-10-07 20:18:49 +00:00
````html {title="layouts/partials/content-header.html"}
< style >
2024-10-07 13:30:53 +00:00
img.bg-white {
background-color: white;
}
img.nobg-white {
background-color: transparent;
}
2024-10-07 20:18:49 +00:00
< / style >
2024-10-07 13:30:53 +00:00
````