Skip to content

Commit 96ff4c0

Browse files
committed
Improve responsive image docs
1 parent 0b41803 commit 96ff4c0

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

docs/classic-ui/images.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,34 +254,49 @@ The `ImageScaling` view explicitly checks the permissions of the current user.
254254
To access image scales, which are normally not accessible to the current user, override the `validate_access` method in `plone.namedfile.scaling.ImageScale`.
255255

256256

257-
## `srcset` configuration
257+
(classic-ui-images-responsive-image-support)=
258+
## Responsive image support
258259

259-
In `/@@imaging-controlpanel` Plone allows you to define HTML {term}`srcset` attributes.
260-
A `srcset` can help the browser serve the best fitting image for the current users situation.
260+
Plone supports the generation of picture tags with `srcset`'s for image optimization.
261+
Additionally you can define `media queries` for {ref}`classic-ui-images-responsive-image-support-art-direction` and further optimization.
262+
263+
The configuration allows to define different picture variants, like `Large`, `Medium`, `Small`.
264+
Users can choose from them in editors like TinyMCE and Developers can use them in templates.
265+
266+
267+
(classic-ui-images-responsive-image-support-picture-variants)=
268+
### Picture variants
269+
270+
In `/@@imaging-controlpanel` Plone allows you to define picture variants with a list of available image scales.
271+
These are used for HTML {term}`srcset` attributes.
272+
A `srcset` attribute can help the browser to serve the best fitting image size for the current users situation.
261273

262274

263275
### default configuration
264276

265-
The default configuration covers `image size optimization` and will provide the Browser with the needed information to load the optimal image.
277+
The default configuration covers `image size optimization` and will provide the Browser with the needed information to load the optimal image size.
266278

267279
```json
268280
{
269281
"large": {
270282
"title": "Large",
271283
"sourceset": [
272-
{"scale": "larger"},
284+
"scale": "larger",
285+
"additionalScales": ["preview", "teaser", "large", "great", "huge"],
273286
],
274287
},
275288
"medium": {
276289
"title": "Medium",
277290
"sourceset": [
278-
{"scale": "teaser"},
291+
"scale": "teaser",
292+
"additionalScales": ["preview", "large", "larger", "great"],
279293
],
280294
},
281295
"small": {
282296
"title": "Small",
283297
"sourceset": [
284-
{"scale": "preview"},
298+
"scale": "preview",
299+
"additionalScales": ["preview", "large", "larger"],
285300
],
286301
},
287302
}
@@ -312,6 +327,7 @@ If we have the following two entries, the `image_srcset` outputfilter will gener
312327
}
313328
```
314329

330+
(classic-ui-images-responsive-image-support-filtering-scales)=
315331
#### Filtering scales
316332

317333
By default for every `srcset` all available scales will be included in the `srcset`.
@@ -345,11 +361,32 @@ Without this parameter all scales which are not globally excluded scales will be
345361
This means the generated `srcset` will contain the scales from `preview` up to `huge`, but not `mini` for example.
346362

347363

364+
(classic-ui-images-responsive-image-support-picture-variant-in-editor)=
365+
#### Hiding a picture variant in editors
366+
367+
It is possible to hide a picture variant in editors.
368+
This is useful when you want to define a picture variant to be used in templates only.
369+
370+
```json
371+
"leadimage": {
372+
"title": "Lead image",
373+
"sourceset": [
374+
{
375+
"scale": "preview",
376+
"additionalScales": ["large", "larger"],
377+
"hideInEditor": True,
378+
},
379+
],
380+
},
381+
```
382+
383+
384+
(classic-ui-images-responsive-image-support-art-direction)=
348385
### Art direction
349386

350387
With `image size optimization` the browser is able to choose the optimal image for each situation.
351-
But we have no control lover which scale the browser will actually use.
352-
To force the Browser to use a zoomed version of an image for smaller screens we can use media queries.
388+
But we have no control over which scale the browser will actually use.
389+
For example to force the Browser to use a zoomed version of an image for smaller screens we can use media queries.
353390
The technique is called [art direction](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images#art_direction).
354391

355392
Let's have a look at a more advanced configuration:

0 commit comments

Comments
 (0)