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

83 lines
2 KiB
Markdown
Raw Permalink Normal View History

+++
2024-10-12 17:28:28 +00:00
categories = ["explanation", "howto"]
description = "How to extend image effects"
2024-10-06 18:37:18 +00:00
options = ["imageEffects"]
title = "Image Effects"
weight = 3
+++
This page shows you, how to configure custom [image effects](authoring/markdown#image-effects) on top of existing ones.
This setting can also [be overridden by your front matter](authoring/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-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 >}}
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).
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 >}}
2024-10-07 13:30:53 +00:00
This would result in
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
### 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
````