##// END OF EJS Templates
Show all post images in gallery
neko259 -
r1755:5aa523da default
parent child Browse files
Show More
@@ -196,13 +196,14 b' class Post(models.Model, Viewable):'
196 196
197 197 return render_to_string('boards/post.html', params)
198 198
199 def get_images(self) -> Attachment:
200 return self.attachments.filter(mimetype__in=FILE_TYPES_IMAGE)
201
199 202 def get_first_image(self) -> Attachment:
200 image = None
201 203 try:
202 image = self.attachments.filter(mimetype__in=FILE_TYPES_IMAGE).earliest('id')
204 return self.get_images().earliest('-id')
203 205 except Attachment.DoesNotExist:
204 pass
205 return image
206 return None
206 207
207 208 def set_global_id(self, key_pair=None):
208 209 """
@@ -18,19 +18,19 b''
18 18 <div id="posts-table">
19 19 {% if posts %}
20 20 {% for post in posts %}
21 <div class="gallery_image">
22 {% with post.get_first_image as image %}
23 {% autoescape off %}
24 {{ image.get_view }}
25 <div class="gallery_image_metadata">
26 {{ image.get_size.0 }}x{{ image.get_size.1 }}
27 {% image_actions image.file.url request.get_host %}
28 <br />
29 <a href="{{ post.get_absolute_url }}">>>{{ post.id }}</a>
30 </div>
31 {% endautoescape %}
32 {% endwith %}
33 </div>
21 {% for image in post.get_images %}
22 <div class="gallery_image">
23 {% autoescape off %}
24 {{ image.get_view }}
25 <div class="gallery_image_metadata">
26 {{ image.get_size.0 }}x{{ image.get_size.1 }}
27 {% image_actions image.file.url request.get_host %}
28 <br />
29 <a href="{{ post.get_absolute_url }}">>>{{ post.id }}</a>
30 </div>
31 {% endautoescape %}
32 </div>
33 {% endfor %}
34 34 {% endfor %}
35 35 {% else %}
36 36 {% trans 'No images.' %}
General Comments 0
You need to be logged in to leave comments. Login now