Skip to content

Commit e29ace9

Browse files
authored
chore(classic-ui/images): add a code snippet
That showcases how to generate a responsive image with it `srcset`.
1 parent 2d96333 commit e29ace9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/classic-ui/images.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ Additionally, you can define [media queries](https://developer.mozilla.org/en-US
291291
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:
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+
```
294302

295303
(classic-ui-images-responsive-image-support-picture-variants)=
296304

@@ -533,4 +541,4 @@ This information shows we have everything we need to generate our image URLs, wi
533541
width="${python: preview['width']}"
534542
height="${python: preview['height']}" />
535543
</li>
536-
```
544+
```

0 commit comments

Comments
 (0)