This commit is contained in:
@@ -5,6 +5,7 @@ from grapple.models import (
|
||||
GraphQLString,
|
||||
)
|
||||
from wagtail.images.models import AbstractImage, AbstractRendition, Image
|
||||
from wagtail.search import index
|
||||
|
||||
|
||||
class CustomImage(AbstractImage):
|
||||
@@ -48,6 +49,15 @@ class CustomImage(AbstractImage):
|
||||
GraphQLString("attribution"),
|
||||
]
|
||||
|
||||
# Wagtail indexes title, description and tags. Editors describe the picture
|
||||
# in `alt` rather than in `description`, so it is boosted alongside title.
|
||||
search_fields = AbstractImage.search_fields + [
|
||||
index.SearchField("alt", boost=10),
|
||||
index.AutocompleteField("alt"),
|
||||
index.SearchField("attribution"),
|
||||
index.AutocompleteField("attribution"),
|
||||
]
|
||||
|
||||
|
||||
class Rendition(AbstractRendition):
|
||||
image = models.ForeignKey(CustomImage, on_delete=models.CASCADE, related_name="renditions")
|
||||
|
||||
Reference in New Issue
Block a user