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
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.
13
16
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.
15
18
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.
17
19
```{note}
18
20
We will use the image object as context in the following examples.
19
21
```
20
22
23
+
(classic-ui-images-default-scales-label)=
24
+
21
25
## Default scales
22
26
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:
24
28
25
29
* large 768:768
26
30
* preview 400:400
@@ -30,32 +34,41 @@ Plone allows you in the `/@@imaging-controlpanel` to configure which scales are
30
34
* icon 32:32
31
35
* listing 16:16
32
36
33
-
You can add or change scale as you like.
37
+
You can add or change scales as you like.
34
38
35
39
40
+
(classic-ui-images-image-resolving-by-uri-label)=
41
+
36
42
## Image resolving by URI
37
43
38
44
Plone can resolve an image scale via URI in different ways.
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.
59
72
60
73
61
74
(classic-ui-images-image-tag-label)=
@@ -95,6 +108,8 @@ tag = scale_util.tag(
95
108
)
96
109
```
97
110
111
+
If you pass additional kwargs to `tag`, they become attributes on `tag`.
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:
158
176
159
177
```xml
160
178
<divtal: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
167
185
</div>
168
186
```
169
187
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:
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:
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