Skip to content

Commit 33e626a

Browse files
authored
[image] Update schema docs (#5156)
1 parent 66b5032 commit 33e626a

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

components/image.rst

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,39 @@ Configuration variables:
8383
additionally need to have the python ``cairosvg`` package installed. These are automatically installed when
8484
setting up ESPHome via the usual methods.
8585

86+
87+
Setting defaults
88+
----------------
89+
90+
For the situation where most or all of your images share common attributes, you can use another schema style to provide default values. In this case
91+
the ``defaults:`` option will provide fallback values for all images. When using this format the ``images:`` key takes a list of image definitions.
92+
93+
.. code-block:: yaml
94+
95+
image:
96+
defaults:
97+
type: rgb565
98+
transparency: opaque
99+
resize: 100x100
100+
images:
101+
- file: "image1.png"
102+
id: image1
103+
- file: "image2.png"
104+
id: image2
105+
resize: 200x200 # overrides the default resize
106+
86107
Grouping images by type
87108
-----------------------
88109

89-
You can group images by type to make it easier to manage them. This is useful when you have a lot of images to be encoded in the same way, and avoids having to repeat the same type for each image. The type name is used as the key for the group. For example:
110+
You can group images by type to make it easier to manage them. This is useful when you have a lot of images to be encoded in the same way,
111+
and avoids having to repeat the same type for each image. A ``defaults:`` group can be used to specify default values other than the type.
112+
The type name is used as the key for the group. For example:
90113

91114
.. code-block:: yaml
92115
93116
image:
117+
defaults:
118+
resize: 100x100
94119
grayscale:
95120
- file: "image1.png"
96121
id: image1
@@ -119,23 +144,6 @@ In addition, the default transparency type can be set within a type group by usi
119144
opaque:
120145
- file: "image2.png"
121146
122-
For the situation where most or all of your images share common attributes, you can use another schema style to provide default values. In this case
123-
the ``defaults:`` option will provide fallback values for all images. When using this format the ``images:`` key takes only a list of image definitions.
124-
125-
.. code-block:: yaml
126-
127-
image:
128-
defaults:
129-
type: rgb565
130-
transparency: opaque
131-
resize: 100x100
132-
images:
133-
- file: "image1.png"
134-
id: image1
135-
- file: "image2.png"
136-
id: image2
137-
resize: 200x200 # overrides the default resize
138-
139147
Displaying Images
140148
-----------------
141149

0 commit comments

Comments
 (0)