Skip to content

Commit facc095

Browse files
committed
English grammar fixes
Surround inline literals with backticks Add html_meta tags Add labels for future navigation ease
1 parent c734f32 commit facc095

File tree

1 file changed

+72
-51
lines changed

1 file changed

+72
-51
lines changed

docs/classic-ui/images.md

Lines changed: 72 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,118 @@
11
---
22
html_meta:
3-
"description": ""
4-
"property=og:description": ""
5-
"property=og:title": ""
6-
"keywords": ""
3+
"description": "Image resolution and scaling in Plone Classic UI"
4+
"property=og:description": "Image resolution and scaling in Plone Classic UI"
5+
"property=og:title": "Image resolving and scaling"
6+
"keywords": "Plone, Classic UI, classic-ui, image, resize, scale"
77
---
88

99
(classic-ui-images-label)=
1010

1111
# Image resolving and scaling
1212

13-
Image scaling is done in plone.namedfile.scaling and most interesting the ImageScaling view.
13+
Image scaling is done in `plone.namedfile.scaling`, specifically in the `ImageScaling` view.
14+
15+
16+
(classic-ui-images-image-tag-label)=
1417

1518
## Image tag
1619

17-
To get a HTML tag for an scaled image, you can use the ImageScaling view as follow:
20+
To get an HTML tag for a scaled image, you can use the `ImageScaling` view as follows:
1821

1922
```python
2023
from plone import api
2124

22-
scale_util = api.content.get_view('images', context, request)
23-
tag = scale_util.tag('leadimage', scale='mini')
25+
scale_util = api.content.get_view("images", context, request)
26+
tag = scale_util.tag("leadimage", scale="mini")
2427
```
2528

26-
or to get a specific size:
29+
To get a specific image size:
2730

2831
```python
2932
from plone import api
3033

31-
scale_util = api.content.get_view('images', context, request)
32-
tag = scale_util.tag('leadimage', width="600", height="200")
34+
scale_util = api.content.get_view("images", context, request)
35+
tag = scale_util.tag("leadimage", width="600", height="200")
3336
```
3437

35-
The first argument is the field name, followed by one of the following arguments:
38+
The complete list of arguments with their default values is shown in the following example.
39+
40+
```python
41+
from plone import api
42+
43+
scale_util = api.content.get_view("images", context, request)
44+
tag = scale_util.tag(
45+
fieldname=None,
46+
scale=None,
47+
height=None,
48+
width=None,
49+
direction="thumbnail"
50+
)
51+
```
3652

37-
fieldname=None,
38-
scale=None,
39-
height=None,
40-
width=None,
41-
direction="thumbnail",
4253

54+
(classic-ui-images-image-scaling-no-tag-creation-label)=
4355

4456
## Image scaling without tag creation
4557

46-
To just get the scaling infos, without creating a HTML tag, you can use the ImageScaling view as follow:
58+
To get the scaling information only without creating an HTML tag, you can use the `ImageScaling` view as follows:
4759

4860
```python
4961
from plone import api
5062

51-
scale_util = api.content.get_view('images', context, request)
52-
image_scale = scale_util.scale('leadimage', scale='mini')
53-
print(image_scale.url) # http://localhost:8080/Plone/enl/@@images/3d182f34-8773-4f20-a79d-8774c3151b7e.jpeg
54-
print(image_scale.width) # 200
55-
print(image_scale.height) # 110
63+
scale_util = api.content.get_view("images", context, request)
64+
image_scale = scale_util.scale("leadimage", scale="mini")
65+
print(image_scale.url)
66+
print(image_scale.width)
67+
print(image_scale.height)
68+
```
69+
70+
This will produce the following output:
71+
72+
```console
73+
http://localhost:8080/Plone/enl/@@images/3d182f34-8773-4f20-a79d-8774c3151b7e.jpeg
74+
200
75+
110
5676
```
5777

58-
the most important properties:
78+
The most important properties are the following:
5979

60-
- data
61-
- fieldname
62-
- height
63-
- mimetype
64-
- srcset
65-
- srcset_attribute
66-
- tag
67-
- uid
68-
- url
69-
- width
80+
- `data`
81+
- `fieldname`
82+
- `height`
83+
- `mimetype`
84+
- `srcset`
85+
- `srcset_attribute`
86+
- `tag`
87+
- `uid`
88+
- `url`
89+
- `width`
7090

71-
You can get a tag from this point too:
72-
```python
91+
At this point, you can also get an HTML tag, since you have created an instance of `api.content.get_view` in `scale_util`:
92+
93+
```pycon
7394
>>> print(image_scale.tag)
7495

7596
<img src="http://localhost:8080/Plone/news/newsitem1/@@images/9f676d46-0cb3-4512-a831-a5db4079bdfa.jpeg" alt="News Item 1!" title="News Item 1" height="21" width="32" srcset="http://localhost:8080/Plone/news/newsitem1/@@images/4a68513c-cffd-4de0-8a35-80627945b80f.jpeg 2x, http://localhost:8080/Plone/news/newsitem1/@@images/c32929c6-cb89-4ce7-846f-38adf29c09a4.jpeg 3x" />
7697
```
7798

78-
or to get a specific size:
99+
You can also get an HTML tag with a specific size:
79100

80101
```python
81102
from plone import api
82103

83-
scale_util = api.content.get_view('images', context, request)
84-
tag = scale_util.scale('leadimage', width="600", height="200")
104+
scale_util = api.content.get_view("images", context, request)
105+
tag = scale_util.scale("leadimage", width="600", height="200")
85106
```
86107

87-
The first argument is the field name, followed by one of the following arguments:
88108

89-
fieldname=None,
90-
scale=None,
91-
height=None,
92-
width=None,
93-
direction="thumbnail",
109+
(classic-ui-images-scaling-direction-deprecated-in-favor-of-label)=
94110

95-
## Scaling direction / mode
111+
## Scaling `direction` deprecated in favor of `mode`
96112

97-
The actual scaling is done in plone.scale:
98-
In plone scale the `direction` argument is deprecated in favor of `mode` and values are converted as follow:
113+
The actual scaling is done in `plone.scale`.
114+
In Plone 6 in `plone.scale`, the `direction` argument is deprecated in favor of `mode`.
115+
The values should be converted as follows:
99116

100117
direction values | mode values
101118
-----------------|------------
@@ -106,9 +123,13 @@ up | cover
106123
keep | scale
107124
thumbnail | scale
108125

109-
For now plone.namedfile is still expecting the direction argument with the old values.
126+
For now `plone.namedfile` still expects the `direction` argument with the old values.
110127

111-
## Permissions
112128

113-
The ImageScaling view is checking explicitly the permissions the current user has, in case you want to access objects which are normally not accessible to the current user, you have to override the validate_access method in ImageScale. In Products.EasyNewsletter you can find an example of that.
129+
(classic-ui-images-label)=
130+
131+
## Permissions
114132

133+
The `ImageScaling` view explicitly checks the permissions of the current user.
134+
If you want to access objects which are normally not accessible to the current user, then you have to override the `validate_access` method in `ImageScale`.
135+
In `Products.EasyNewsletter` you can find an example of that.

0 commit comments

Comments
 (0)