Skip to content

Commit e4fb5e3

Browse files
committed
Add srcset info to images chapter
1 parent 9cc01bf commit e4fb5e3

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

docs/classic-ui/images.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,83 @@ Other options are:
247247

248248
The `ImageScaling` view explicitly checks the permissions of the current user.
249249
To access image scales, which are normally not accessible to the current user, override the `validate_access` method in `plone.namedfile.scaling.ImageScale`.
250+
251+
252+
## srcset configuration
253+
254+
In `/@@imaging-controlpanel` Plone allows you to define srcset's.
255+
A srcset can help the Browser to serve the best fitting image for the current users situation.
256+
Which image scale is best for the user can be decided on different metrics.
257+
258+
259+
### viewport size
260+
261+
The first is metric would be the viewport size.
262+
263+
```json
264+
{
265+
"scale": "large",
266+
"media": "(max-width:800px)"
267+
},
268+
{
269+
"scale": "larger"
270+
}
271+
```
272+
273+
With this definition the Browser will use the large scale (800px) when the viewport size is max 800px.
274+
When the viewport size is greater then 800px, the Browser will use the larger scale (1000px).
275+
276+
277+
### Pixel density
278+
279+
Another metric is the pixel density of the users screen.
280+
This metric defines how many DPI per pixel the Screen is using.
281+
282+
```json
283+
{
284+
"scale": "huge",
285+
"media": "(min-resolution: 192dpi), (-webkit-min-device-pixel-ratio: 2)"
286+
},
287+
{
288+
"scale": "large"
289+
}
290+
```
291+
292+
With this definition the Browser will use the huge scale (1600px) when the screen has a density of 192 DPI per pixel also knows as `2x`.
293+
We use here two different media queries to also support older Safari versions.
294+
Mobile devices with Safari like iPhones are still only supporting the old non-standard media query.
295+
If you don't care about IE support you can also use `min-resolution: 2dppx` which is closer to `2x`.
296+
The most common variants are:
297+
298+
- `1x`: 96 DPI per pixel
299+
- `1.25x`: 120 DPI per pixel
300+
- `1.5x`: 144 DPI per pixel
301+
- `2x`: 192 DPI per pixel
302+
- `3x`: 288 DPI per pixel
303+
304+
305+
### Combining viewport size and pixel density
306+
307+
It is also possible to combine the two metrics.
308+
309+
```json
310+
{
311+
"scale": "great",
312+
"media": "(max-width:799px) and (min-resolution: 144dpi), (max-width:799px) and (-webkit-min-device-pixel-ratio: 1.5)"
313+
},
314+
{
315+
"scale": "large",
316+
"media": "(max-width:799px)"
317+
},
318+
{
319+
"scale": "huge",
320+
"media": "(min-width:800px) and (min-resolution: 144dpi), (max-width:800px) and (-webkit-min-device-pixel-ratio: 1.5)"
321+
},
322+
{
323+
"scale": "larger",
324+
"media": "(min-width:800px)"
325+
},
326+
{
327+
"scale": "huge"
328+
}
329+
```

0 commit comments

Comments
 (0)