hugo-theme-relearn/exampleSite/content/configuration/customization/imageeffects.en.md

95 lines
2 KiB
Markdown
Raw Normal View History

+++
description = "How to extend image effects"
2024-10-06 18:37:18 +00:00
options = ["imageEffects"]
title = "Image Effects"
weight = 3
+++
2024-10-07 13:30:53 +00:00
This page shows you, how to configure custom [image effects](content/markdown#image-effects) on top of existing ones.
2024-10-07 13:30:53 +00:00
For a detailed usage example, see [this page](content/imageeffects).
2024-10-07 13:30:53 +00:00
If you don't configure anything in your `hugo.toml`, the image effects default to
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 >}}
2024-10-07 20:18:49 +00:00
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} You can change these settings in your `hugo.toml`
2024-10-07 13:30:53 +00:00
{{< multiconfig file=hugo >}}
[params]
[params.imageEffects]
border = true
lazy = false
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
2024-10-07 13:30:53 +00:00
This would result in
2024-03-02 10:04:52 +00:00
{{< multiconfig >}}
2024-10-07 20:18:49 +00:00
[imageEffects]
border = true
lazy = false
lightbox = true
shadow = false
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
2024-10-07 13:30:53 +00:00
## Adding Custom Effects
2024-10-07 13:30:53 +00:00
You can add new effects with boolean values
2024-10-07 13:30:53 +00:00
{{< multiconfig file=hugo >}}
[params]
[params.imageEffects]
bg-white = true
{{< /multiconfig >}}
2024-10-07 13:30:53 +00:00
Result:
2024-10-06 18:37:18 +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 >}}
2024-10-07 13:30:53 +00: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
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)
````
### Result
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">
````
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:
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
````