-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add social fields to API meta fields and add serializer for social im…
…age (#166) Co-authored-by: Thibaud Colas <[email protected]>
- Loading branch information
1 parent
b448445
commit 96fc35a
Showing
3 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from wagtail.images.api.fields import ImageRenditionField | ||
from wagtail.images.models import SourceImageIOError | ||
|
||
|
||
class ImageRenditionURLField(ImageRenditionField): | ||
"""A field that serialises a rendition's url.""" | ||
|
||
def to_representation(self, image): | ||
try: | ||
return image.get_rendition(self.filter_spec).full_url | ||
except SourceImageIOError: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters