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
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-10-07 15:30:53 +02:00
This page shows you, how to configure custom [image effects ](content/markdown#image-effects ) on top of existing ones.
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
For a detailed usage example, see [this page ](content/imageeffects ).
2024-03-16 10:00:40 +01:00
2024-10-07 15:30:53 +02:00
If you don't configure anything in your `hugo.toml` , the image effects default to
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
{{< multiconfig > }}
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-07 15:30:53 +02:00
You can change these settings in your `hugo.toml`
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
{{< multiconfig file = hugo > }}
[params]
[params.imageEffects]
border = true
lazy = false
2024-03-02 11:04:52 +01:00
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
This would result in
2023-08-25 19:09:50 +02:00
2024-03-02 11:04:52 +01:00
{{< multiconfig > }}
2024-10-07 15:30:53 +02:00
[params]
[params.imageEffects]
border = true
lazy = false
lightbox = true
shadow = false
2024-03-02 11:04:52 +01:00
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
## Adding Custom Effects
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
You can add new effects with boolean values
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
{{< multiconfig file = hugo > }}
[params]
[params.imageEffects]
bg-white = true
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
Result:
2024-10-06 20:37:18 +02:00
2024-10-07 15:30:53 +02:00
{{< multiconfig > }}
2024-10-06 20:37:18 +02:00
[params]
[params.imageEffects]
bg-white = true
2024-10-07 15:30:53 +02:00
border = true
lazy = false
2024-10-06 20:37:18 +02:00
lightbox = true
shadow = false
{{< / multiconfig > }}
2023-08-25 19:09:50 +02:00
2024-10-07 15:30:53 +02:00
## Styling Custom Effects
If the effective image 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
### Example
````markdown

````
### Result
````html
< img src = "https://octodex.github.com/images/minion.png" loading = "lazy" alt = "Minion" class = "bg-white border nolazy lightbox noshadow" >
````
Styles for default image effets are contained in the theme. Add custom styles for your extension image effects to `layouts/partials/content-header.html` .
In the above example you could add styles for both cases:
````css
img.bg-white {
background-color: white;
}
img.nobg-white {
background-color: transparent;
}
````