diff --git a/boards/models/post/__init__.py b/boards/models/post/__init__.py --- a/boards/models/post/__init__.py +++ b/boards/models/post/__init__.py @@ -196,13 +196,14 @@ class Post(models.Model, Viewable): return render_to_string('boards/post.html', params) + def get_images(self) -> Attachment: + return self.attachments.filter(mimetype__in=FILE_TYPES_IMAGE) + def get_first_image(self) -> Attachment: - image = None try: - image = self.attachments.filter(mimetype__in=FILE_TYPES_IMAGE).earliest('id') + return self.get_images().earliest('-id') except Attachment.DoesNotExist: - pass - return image + return None def set_global_id(self, key_pair=None): """ diff --git a/boards/templates/boards/thread_gallery.html b/boards/templates/boards/thread_gallery.html --- a/boards/templates/boards/thread_gallery.html +++ b/boards/templates/boards/thread_gallery.html @@ -18,19 +18,19 @@