我注意到我们可以在 wagtail 上设置自定义图像模型:https ://docs.wagtail.io/en/v2.9/advanced_topics/images/custom_image_model.html
我正在尝试在上传最大 200*220px 期间添加一个自动焦点。
我按照上面的文档做了很多尝试。
从 django.db 导入模型
从 wagtail.images.models 导入 Image、AbstractImage、AbstractRendition
class CustomImage(AbstractImage):
# Add any extra fields to image here
# eg. To add a caption field:
# caption = models.CharField(max_length=255, blank=True)
admin_form_fields = Image.admin_form_fields + (
# Then add the field names here to make them appear in the form:
# 'caption',
)
class CustomRendition(AbstractRendition):
image = models.ForeignKey(CustomImage, on_delete=models.CASCADE, related_name='renditions')
class Meta:
unique_together = (
('image', 'filter_spec', 'focal_point_key'),
谁能帮我完成设置自定义焦点?
谢谢阿纳穆尔