|
@@ -13,7 +13,18 @@ from wagtail.contrib.typed_table_block.blocks import TypedTableBlock
|
|
|
from wagtail.embeds.blocks import EmbedBlock
|
|
|
from wagtail.images.blocks import ImageBlock
|
|
|
|
|
|
-from bakerydemo.base.blocks import BlockQuote, HeadingBlock
|
|
|
+from bakerydemo.base.blocks import (
|
|
|
+ BlockQuote,
|
|
|
+ HeadingBlock,
|
|
|
+ get_image_api_representation,
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+class CustomImageBlock(ImageBlock):
|
|
|
+ def get_api_representation(self, value, context=None):
|
|
|
+ data = super().get_api_representation(value, context)
|
|
|
+ data["image"] = get_image_api_representation(value)
|
|
|
+ return data
|
|
|
|
|
|
|
|
|
class RecipeStepBlock(StructBlock):
|
|
@@ -57,7 +68,7 @@ class RecipeStreamBlock(StreamBlock):
|
|
|
("text", CharBlock()),
|
|
|
("numeric", FloatBlock()),
|
|
|
("rich_text", RichTextBlock()),
|
|
|
- ("image", ImageBlock()),
|
|
|
+ ("image", CustomImageBlock()),
|
|
|
],
|
|
|
group="Content",
|
|
|
description=(
|
|
@@ -104,7 +115,7 @@ class RecipeStreamBlock(StreamBlock):
|
|
|
},
|
|
|
)
|
|
|
|
|
|
- image_block = ImageBlock(group="Media")
|
|
|
+ image_block = CustomImageBlock(group="Media")
|
|
|
embed_block = EmbedBlock(
|
|
|
help_text="Insert an embed URL e.g https://www.youtube.com/watch?v=SGJFWirQ3ks",
|
|
|
icon="media",
|