You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/classic-ui/images.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -501,6 +501,39 @@ Please note that this example has the `resolve_uid_and_caption` filter disabled
501
501
The real `src` URLs look more like `http://localhost:8080/Plone50/dsc04791.jpg/@@images/778f9c06-36b0-485d-ab80-12c623dc4bc3.jpeg`.
502
502
```
503
503
504
+
### All image scales in the srcset
505
+
506
+
Modern browsers can download appropriate sized images depending on their viewport width when URLs and widths are correctly provided in an attribute called `srcset` and the viewport width is provided in the attribute `sizes`.
This example will render the HTML `img` tag with the URLs of all scales configured in Plone, calculating the width of each of the scales, and will add the `sizes="90vw"` attribute.
516
+
The `sizes` attribute instructs the browser to retrieve the image that best fits in 90% of the current viewport width.
517
+
518
+
This means that the appropriate scaled image will be downloaded and displayed.
519
+
520
+
This also means that the developer does not need to worry about creating a specific scale.
521
+
Instead they only need to provide the correct media query to signal the required width.
522
+
523
+
The `scrset` method of the `@@images` view also takes all other parameters that are HTML attributes of the `img` tag, such as `title`, `alt` or `loading`.
While using this approach may be useful for projects, using it in reusable add-ons is not recommended, because it may require overriding it to your needs in a project.
535
+
Use configurable picture variants instead.
536
+
```
504
537
## Image scales from catalog brain
505
538
506
539
For all `NamedBlobImage` fields, we can get existing scale information directly from the catalog brain.
0 commit comments