Merge pull request #3039 from dato/ap_image_url

Fix creation of covers for ActivityPub imports
This commit is contained in:
Mouse Reeve 2023-11-02 14:44:44 -07:00 committed by GitHub
commit ae51dcec63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -483,10 +483,12 @@ class ImageField(ActivitypubFieldMixin, models.ImageField):
image_slug = value
# when it's an inline image (User avatar/icon, Book cover), it's a json
# blob, but when it's an attached image, it's just a url
if hasattr(image_slug, "url"):
url = image_slug.url
elif isinstance(image_slug, str):
if isinstance(image_slug, str):
url = image_slug
elif isinstance(image_slug, dict):
url = image_slug.get("url")
elif hasattr(image_slug, "url"): # Serialized to Image/Document object?
url = image_slug.url
else:
return None