Skip to content

Commit b6c7781

Browse files
committed
Fix MyST syntax, English grammar
Add MyST labels to section headings Add suggestions from @jensens
1 parent f715255 commit b6c7781

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

docs/classic-ui/images.md

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,26 @@ html_meta:
55
"property=og:title": "Image resolving and scaling"
66
"keywords": "Plone, Classic UI, classic-ui, image, resize, scale"
77
---
8+
89
(classic-ui-images-label)=
910

1011
# Image handling
1112

12-
The default content types and behaviors are using a `plone.namedfile.NamedBlobImage` field for all images.
13+
The default content types and behaviors use the field `plone.namedfile.NamedBlobImage` for all images.
14+
15+
For this field, image scaling and HTML tag creation is provided by the `plone.namedfile.scaling` module, specifically in the [`ImageScaling`](https://github.com/plone/plone.namedfile/blob/ecf33a2bc7a8c61888909bc383b3e08d80888e43/plone/namedfile/scaling.py#L350) view.
1316

14-
For this fields, image scaling and HTML tag creation is provided by the `plone.namedfile.scaling` module, specifically in the [`ImageScaling`](https://github.com/plone/plone.namedfile/blob/ecf33a2bc7a8c61888909bc383b3e08d80888e43/plone/namedfile/scaling.py#L350) view.
17+
Given a Dexterity content type named `news-item1` with a `plone.namedfile.NamedBlobImage` field named `image`, we can use the following APIs to access the image scales and manage scales.
1518

16-
Given a Dexterity content type named `news-item1` with a `plone.namedfile.NamedBlobImage` field named `image`, we can use the following API's to access the image scales and manage scales.
1719
```{note}
1820
We will use the image object as context in the following examples.
1921
```
2022

23+
(classic-ui-images-default-scales-label)=
24+
2125
## Default scales
2226

23-
Plone allows you in the `/@@imaging-controlpanel` to configure which scales are available and what dimensions they should have. By default we have the following scales configured:
27+
In `/@@imaging-controlpanel` Plone allows you to configure which scales are available and what dimensions they should have. By default we have the following scales configured:
2428

2529
* large 768:768
2630
* preview 400:400
@@ -30,32 +34,41 @@ Plone allows you in the `/@@imaging-controlpanel` to configure which scales are
3034
* icon 32:32
3135
* listing 16:16
3236

33-
You can add or change scale as you like.
37+
You can add or change scales as you like.
3438

3539

40+
(classic-ui-images-image-resolving-by-uri-label)=
41+
3642
## Image resolving by URI
3743

3844
Plone can resolve an image scale via URI in different ways.
3945

46+
47+
(classic-ui-images-by-field-and-scale-name-label)=
48+
4049
### By field and scale name
4150

4251
Given our `news-item1` with the field `image`, we can get the name scale `thumb` as follows:
4352

44-
http://localhost:8080/Plone/news-item1/@@images/image/thumb
53+
`http://localhost:8080/Plone/news-item1/@@images/image/thumb`
4554

4655
To get the original image, you can leave out the scale:
4756

48-
http://localhost:8080/Plone/news-item1/@@images/image
57+
`http://localhost:8080/Plone/news-item1/@@images/image`
4958

5059

60+
(classic-ui-images-by-cacheable-scale-uid-name-label)=
5161

5262
### By cacheable scale UID name
5363

54-
When an image scale was created, it will be cached under the name `UID.jpeg` in the object annotations and can be resolved by it as follows:
64+
When an image scale is created, it will be cached under the name `UID.jpeg` in the object annotations.
65+
It can be resolved as follows:
5566

56-
http://localhost:8080/Plone/news-item1/@@images/3d182f34-8773-4f20-a79d-8774c3151b7e.jpeg
67+
`http://localhost:8080/Plone/news-item1/@@images/3d182f34-8773-4f20-a79d-8774c3151b7e.jpeg`
5768

58-
This very useful for caching URL's in Varnish or the Browser. In case the scale definitions have changed, they will be saved again under a different UID, so that the URL will change and enforce the Browser or a cache proxy like Varnish to fetch it again.
69+
This is useful for caching URLs in Varnish or the browser.
70+
In case the uploaded image or scale definitions have changed, they will be saved again under a different UID.
71+
This changes the URL and forces either the browser, or a cache proxy such as Varnish, to fetch it again.
5972

6073

6174
(classic-ui-images-image-tag-label)=
@@ -95,6 +108,8 @@ tag = scale_util.tag(
95108
)
96109
```
97110

111+
If you pass additional kwargs to `tag`, they become attributes on `tag`.
112+
98113

99114
(classic-ui-images-image-scaling-no-tag-creation-label)=
100115

@@ -106,8 +121,8 @@ To get the scaling information only without creating an HTML tag, you can use th
106121
from plone import api
107122

108123
scale_util = api.content.get_view("images", context, request)
109-
# on the following line "image" is the field name.
110-
# The default Image content types field name is "image".
124+
# The default `Image` content type's field name is "image".
125+
# On the following line of code, "image" is the field name.
111126
image_scale = scale_util.scale("image", scale="mini")
112127
print(image_scale.url)
113128
print(image_scale.width)
@@ -152,9 +167,12 @@ scale_util = api.content.get_view("images", context, request)
152167
tag = scale_util.scale("image", width="600", height="200")
153168
```
154169

170+
(classic-ui-images-using-image_scale0-in-templates-label)=
171+
155172
### Using image_scale in templates
156173

157-
You could use the URL-variant from above, but that would be an an uncached version. To create a cached scale in a page template you can do the following:
174+
You could use the URL-variant from above, but that would be an uncached version.
175+
To create a cached scale in a page template you can do the following:
158176

159177
```xml
160178
<div tal:define="scale_view context/@@images;
@@ -167,22 +185,24 @@ You could use the URL-variant from above, but that would be an an uncached versi
167185
</div>
168186
```
169187

170-
or you can just get the HTML tag back and replace the current tag with it:
188+
Or you can get the HTML tag back, and replace the current tag with it:
171189

172190
```xml
173191
<div tal:define="scale_view context/@@images">
174192
<img tal:replace="structured python: scale_view.tag('image', 'mini')">
175193
</div>
176194
```
177195

178-
You can also provide the following keyword arguments to set title, alt, css_class for the generated tag:
196+
You can also provide the following keyword arguments to set `title`, `alt`, or `css_class` for the generated tag:
179197

180198
```xml
181199
<div tal:define="scale_view context/@@images">
182200
<img tal:replace="structured python: scale_view.tag('banner', 'mini', title='The Banner', alt='Alternative text', css_class='banner')">
183201
</div>
184202
```
185203

204+
(classic-ui-images-get-image_scale-by-cached-uid-name-label)=
205+
186206
### Get image_scale by cached UID name
187207

188208
If you only have the cached image name from an URL and need to get the image scale, unfortunately you can't use restrictedTraverse(), as this will not be able to resolve the scale. But you can use this workaround, by calling the `publishTraverse` method in `ImageScaling` directly:
@@ -202,25 +222,25 @@ image_scale = scaling_util.publishTraverse(context.REQUEST, groups[1])
202222
```
203223

204224

205-
(classic-ui-images-scaling-direction-deprecated-in-favor-of-label)=
225+
(classic-ui-images-scaling-direction-label)=
206226

207227
## Scaling `direction`
208228

209229
The default direction is `thumbnail`.
210230

211231
Other options are:
212232

213-
* scale-crop-to-fit
214-
* down
215-
* scale-crop-to-fill
216-
* up
217-
* keep
218-
* thumbnail
233+
* `down`
234+
* `keep`
235+
* `scale-crop-to-fill`
236+
* `scale-crop-to-fit`
237+
* `thumbnail`
238+
* `up`
219239

220240

221241
(classic-ui-images-permissions-label)=
222242

223243
## Permissions
224244

225245
The `ImageScaling` view explicitly checks the permissions of the current user.
226-
To access image scales which are normally not accessible to the current user, override the `validate_access` method in `plone.namedfile.scaling.ImageScale`.
246+
To access image scales, which are normally not accessible to the current user, override the `validate_access` method in `plone.namedfile.scaling.ImageScale`.

0 commit comments

Comments
 (0)