Cut down release note for image prefetching and add changelog entry

pull/8364/head
Matt Westcott 2022-04-14 12:55:34 +01:00
rodzic 7838e58095
commit f5919513d5
2 zmienionych plików z 2 dodań i 33 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ Changelog
* Phase out special-purpose panel types (`StreamFieldPanel`, `RichTextFieldPanel`, `ImageChooserPanel`, `DocumentChooserPanel`, `PageChooserPanel`, `SnippetChooserPanel`) in favour of `FieldPanel` (Matt Westcott)
* Implement splitting of rich text blocks within StreamField (Jacob Topp-Mugglestone)
* Add support for image rendition prefetching (Andy Babic)
* Upgrade ESLint and Stylelint configurations to latest shared Wagtail configs (Thibaud Colas, Paarth Agarwal)
* Major updates to frontend tooling; move Node tooling from Gulp to Webpack, upgrade to Node v16 and npm v8, eslint v8, stylelint v14 and others (Thibaud Colas)
* Change comment headers date formatting to use browser APIs instead of requiring a library (LB (Ben Johnston))

Wyświetl plik

@ -58,39 +58,7 @@ Trying to upload an image that's a duplicate of one already in the image library
### Image renditions can now be prefetched
When using a queryset to render a list of items with images, you can now make use of Django's built-in ``prefetch_related()`` queryset method to prefetch the renditions needed for rendering with a single extra query. For long lists of items, or where multiple renditions are used for each item, this can provide a significant boost to performance.
For example, say you were rendering a list of events (with thumbnail images for each). The queryset for your source data might look something like this:
```python
EventPage.objects.live().select_related("listing_image")
```
Now that renditions are prefetchable, you can reduce the number of additional database queries needed for rendering by updating the original queryset like so:
```python
EventPage.objects.live().select_related("listing_image").prefetch_related("listing_image__renditions")
```
If each image in your project has large numbers of renditions, you might want to consider using a ``Prefetch`` object to select only the renditions you need. For example:
```python
from django.db.models import Prefetch
from wagtail.images import get_image_model
# These are the renditions required for rendering
renditions = get_image_model().get_rendition_model().objects.filter(
filter_spec__in=["fill-300x186", "fill-600x400", "fill-940x680"]
)
# `Prefetch` is used to only fetch the required renditions
events = EventPage.objects.live().select_related("listing_image").prefetch_related(
Prefetch("listing_image__renditions", queryset=renditions)
)
```
This feature was developed by Andy Babic.
When using a queryset to render a list of items with images, you can now make use of Django's built-in ``prefetch_related()`` queryset method to prefetch the renditions needed for rendering with a single extra query. For long lists of items, or where multiple renditions are used for each item, this can provide a significant boost to performance. This feature was developed by Andy Babic.
### Other features