Skip to content

Commit

Permalink
fix filenotfound error
Browse files Browse the repository at this point in the history
  • Loading branch information
jperelli committed Jun 27, 2024
1 parent 9e1fee4 commit b758b4c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/core/templatetags/pngtowebp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ def pngtowebp(path):

@register.filter
def pngorwebpurl(filefield):
if filefield.storage.exists(pngtowebp(filefield.file.name)):
return pngtowebp(filefield.url)
else:
try:
if filefield.storage.exists(pngtowebp(filefield.file.name)):
return pngtowebp(filefield.url)
else:
return filefield.url
except FileNotFoundError as e:
return filefield.url

0 comments on commit b758b4c

Please sign in to comment.