With Wagtail 1.9, you can change the presentation of the block API in StreamField by overriding the method get_api_representation()in the block.
In your example, we can override the method of ImageChooserBlock itself:
class ImageSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = wagtail.wagtailimages.get_image_model()
fields = ['title', 'file', 'width', 'height', 'file_size']
class APIImageChooserBlock(ImageChooserBlock):
def get_api_representation(self, value, context=None):
return ImageSerializer(context=context).to_representation(value)
@wagtail.wagtailsnippets.models.register_snippet
class MySnippetForAPI(models.Model):
title = models.CharField(max_length=80)
content = StreamField([
('heading', blocks.CharBlock()),
('paragraph', blocks.RichTextBlock()),
('image', APIImageChooserBlock())
])
https://github.com/wagtail/wagtail/blob/b6ee2db6ac8dbf4b47a81f4b2684b7aca8cc2501/wagtail/wagtailcore/blocks/base.py#L244