From a149d1f854b5a1759f7fe559f6e5b6c304e1673c Mon Sep 17 00:00:00 2001 From: Daniel Kirkham Date: Sat, 17 Feb 2024 12:10:08 +1100 Subject: [PATCH] Document the vary_fields property for custom image filters --- docs/extending/custom_image_filters.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/extending/custom_image_filters.md b/docs/extending/custom_image_filters.md index 0a0160f9b0..907166912b 100644 --- a/docs/extending/custom_image_filters.md +++ b/docs/extending/custom_image_filters.md @@ -36,3 +36,17 @@ Use the filter in a template, like so: {% image page.photo width-400 blur-7 %} ``` + +If your custom image filter depends on fields within the ``Image``, for instance those defining the focal point, add a ``vary_fields`` property listing those field names to the subclassed ``FilterOperation``. This is so that a new image rendition is created when any of these fields are changed: + +```python +class BlurOutsideFocusPointOperation(FilterOperation): + vary_fields = ( + "focal_point_width", + "focal_point_height", + "focal_point_x", + "focal_point_y", + ) + + ... +```