@@ -97,13 +97,14 @@ def get_alt_text(self, raw=False):
9797 for rendering alt text inside textarea fields.
9898 """
9999 alt_text = self .alt_text
100- if not alt_text :
100+ if alt_text is None :
101101 alt_text = ''
102102
103103 if not raw :
104+ alt_text = escape .xhtml_escape (alt_text )
104105 alt_text = alt_text .replace ('\n ' , '<br>' )
105106
106- return alt_text
107+ return alt_text . strip ()
107108
108109 def save (self , * args , ** kwargs ):
109110 """
@@ -614,11 +615,12 @@ def thumbnail_url(self):
614615 if sourcefile .type == 'image' :
615616 if self .original_id > 0 :
616617 original = self .original ()
617- size = original .size
618+ if original :
619+ size = original .size
618620 else :
619621 size = self .size
620622 # Fastly I/O won't process images > 50mb, so condition for that
621- if sourcefile .type == 'image' and options .use_fastly and size < 50_000_000 :
623+ if sourcefile .type == 'image' and options .use_fastly and size > 0 and size < 50_000_000 :
622624 return f"https://{ options .cdn_host } /r/{ self .share_key } ?width=100"
623625 else :
624626 return s3_url (options .aws_key , options .aws_secret , options .aws_bucket , \
@@ -633,11 +635,11 @@ def small_thumbnail_url(self):
633635 if sourcefile .type == 'image' :
634636 if self .original_id > 0 :
635637 original = self .original ()
636- size = original .size
638+ if original : size = original .size
637639 else :
638640 size = self .size
639641 # Fastly I/O won't process images > 50mb, so condition for that
640- if sourcefile .type == 'image' and options .use_fastly and size < 50_000_000 :
642+ if sourcefile .type == 'image' and options .use_fastly and size > 0 and size < 50_000_000 :
641643 return f"https://{ options .cdn_host } /r/{ self .share_key } ?width=240&height=184&fit=bounds"
642644 else :
643645 return s3_url (options .aws_key , options .aws_secret , options .aws_bucket , \
0 commit comments