Remove image feature detection signal handler from docs

pull/3379/head
Matt Westcott 2017-02-16 17:10:38 +00:00
rodzic 8c970e4848
commit 25c2be10c3
3 zmienionych plików z 8 dodań i 31 usunięć

Wyświetl plik

@ -58,11 +58,6 @@ Here's an example:
the image and entering custom data happen as two separate actions, and
Wagtail needs to be able to create an image record immediately on upload.
.. note::
If you are using image feature detection, follow these instructions to
enable it on your custom image model: :ref:`feature_detection_custom_image_model`
Then set the ``WAGTAILIMAGES_IMAGE_MODEL`` setting to point to it:
.. code-block:: python

Wyświetl plik

@ -85,28 +85,3 @@ You can manually run feature detection on all images by running the following co
if not image.has_focal_point():
image.set_focal_point(image.get_suggested_focal_point())
image.save()
.. _feature_detection_custom_image_model:
Feature detection and custom image models
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When using a :ref:`custom_image_model`, you need to add a signal handler to
the model to trigger feature detection whenever a new image is uploaded:
.. code-block:: python
# Do feature detection when a user saves an image without a focal point
@receiver(pre_save, sender=CustomImage)
def image_feature_detection(sender, instance, **kwargs):
# Make sure the image doesn't already have a focal point
if not instance.has_focal_point():
# Set the focal point
instance.set_focal_point(instance.get_suggested_focal_point())
.. note::
This example will always run feature detection regardless of whether the
``WAGTAILIMAGES_FEATURE_DETECTION_ENABLED`` setting is set.
Add a check for this setting if you still want it to have effect.

Wyświetl plik

@ -37,7 +37,7 @@ Upgrade considerations
Signals on custom ``Image`` and ``Rendition`` models connected automatically
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Projects using :ref:`custom image models <custom_image_model>` no longer need to set up signal receivers to handle deletion of image files, as this is now handled automatically by Wagtail. The following lines of code should be removed:
Projects using :ref:`custom image models <custom_image_model>` no longer need to set up signal receivers to handle deletion of image files and image feature detection, as these are now handled automatically by Wagtail. The following lines of code should be removed:
.. code-block:: python
@ -51,3 +51,10 @@ Projects using :ref:`custom image models <custom_image_model>` no longer need to
@receiver(post_delete, sender=CustomRendition)
def rendition_delete(sender, instance, **kwargs):
instance.file.delete(False)
# Perform image feature detection (if enabled)
@receiver(pre_save, sender=CustomImage)
def image_feature_detection(sender, instance, **kwargs):
if not instance.has_focal_point():
instance.set_focal_point(instance.get_suggested_focal_point())