96 lines
1.9 KiB
Markdown
Raw Normal View History

+++
description = "How to extend image effects"
2024-10-06 20:37:18 +02:00
options = ["imageEffects"]
title = "Custom Image Effects"
weight = 3
+++
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.
2024-10-07 15:30:53 +02:00
For a detailed usage example, see [this page](content/imageeffects).
2024-10-07 15:30:53 +02:00
If you don't configure anything in your `hugo.toml`, the image effects default to
2024-10-07 15:30:53 +02:00
{{< multiconfig >}}
[params]
[params.imageEffects]
border = false
lazy = true
lightbox = true
shadow = false
2024-03-02 11:04:52 +01:00
{{< /multiconfig >}}
2024-10-07 15:30:53 +02:00
You can change these settings in your `hugo.toml`
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 >}}
2024-10-07 15:30:53 +02:00
This would result in
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 >}}
2024-10-07 15:30:53 +02:00
## Adding Custom Effects
2024-10-07 15:30:53 +02:00
You can add new effects with boolean values
2024-10-07 15:30:53 +02:00
{{< multiconfig file=hugo >}}
[params]
[params.imageEffects]
bg-white = true
{{< /multiconfig >}}
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 >}}
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
![Minion](https://octodex.github.com/images/minion.png)
````
### 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;
}
````