Skip to content

Commit 21df2a7

Browse files
authored
Merge branch '6.0' into integratel-coredev.buildout-2
2 parents fea2941 + 7863c3b commit 21df2a7

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

docs/classic-ui/images.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,34 @@ To access image scales, which are normally not accessible to the current user, o
285285

286286
## Responsive image support
287287

288-
Plone supports the generation of picture tags with `srcset`s for image optimization.
288+
Plone supports the generation of [`picture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture) tags with `srcset`s for image optimization.
289289
Additionally, you can define [media queries](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries) for [art direction](classic-ui-images-responsive-image-support-art-direction) and further optimization.
290290

291-
The configuration allows you to define different picture variants, such as `Large`, `Medium`, or `Small`.
291+
The configuration allows you to define different `picture` variants, such as `Large`, `Medium`, or `Small`.
292292
Users can choose from them in editors, such as TinyMCE, and developers can use them in templates.
293293

294+
To generate a `picture` tag, use the following code.
295+
296+
```python
297+
from plone import api
298+
299+
scale_util = api.content.get_view("images", context, request)
300+
tag = scale_util.picture("image", scale="larger", picture_variant="large")
301+
```
302+
303+
The same can be done from a template.
304+
305+
```xml
306+
<div tal:define="scale_view context/@@images">
307+
<img tal:replace="structure python:scale_view.picture('image', scale='larger', picture_variant='large'" />
308+
</div>
309+
```
294310

295311
(classic-ui-images-responsive-image-support-picture-variants)=
296312

297-
### Picture variants
313+
### `picture` variants
298314

299-
In `/@@imaging-controlpanel` Plone allows you to define picture variants with a list of available image scales.
315+
In `/@@imaging-controlpanel` Plone allows you to define `picture` variants with a list of available image scales.
300316
These are used for HTML {term}`srcset` attributes.
301317
A `srcset` attribute can help the browser to serve the best fitting image size for the current user's display.
302318

@@ -396,10 +412,10 @@ This means the generated `srcset` will contain the scales from `preview` up to `
396412

397413
(classic-ui-images-responsive-image-support-picture-variant-in-editor)=
398414

399-
#### Hiding a picture variant in editors
415+
#### Hiding a `picture` variant in editors
400416

401-
It is possible to hide a picture variant in editors.
402-
This is useful when you want to define a picture variant to be used in templates only.
417+
It is possible to hide a `picture` variant in editors.
418+
This is useful when you want to define a `picture` variant to be used in templates only.
403419

404420
```json
405421
"leadimage": {
@@ -533,4 +549,4 @@ This information shows we have everything we need to generate our image URLs, wi
533549
width="${python: preview['width']}"
534550
height="${python: preview['height']}" />
535551
</li>
536-
```
552+
```

0 commit comments

Comments
 (0)