Skip to content
Snippets Groups Projects
Commit 9a8de804 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch 'fixed-broken-playlists' into 'develop'

Fixed weird bug with versatile imgae field

See merge request funkwhale/funkwhale!331
parents 24132fa1 886680ed
No related branches found
No related tags found
No related merge requests found
......@@ -107,6 +107,13 @@ class PlaylistSerializer(serializers.ModelSerializer):
covers = []
max_covers = 5
for plt in plts:
if not hasattr(plt.track.album.cover, "crop"):
# In some rare situations, we end up with the following stack strace:
# AttributeError: 'VersatileImageFieldFile' object has no attribute 'crop'
# I tend to thing our complex prefetch logic is troubling for versatile
# image field, so wi initialize the missing attribute by hand, cf
# https://github.com/respondcreate/django-versatileimagefield/blob/1.9/versatileimagefield/mixins.py#L108
plt.track.album.cover.build_filters_and_sizers((0.5, 0, 5), False)
url = plt.track.album.cover.crop["200x200"].url
if url in covers:
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment