Show More
@@ -48,7 +48,7 b' class Attachment(models.Model):' | |||
|
48 | 48 | if file_viewer is None: |
|
49 | 49 | file_viewer = AbstractViewer |
|
50 | 50 | |
|
51 | return file_viewer(self.file, self.mimetype).get_view() | |
|
51 | return file_viewer(self.file, self.mimetype, self.hash).get_view() | |
|
52 | 52 | |
|
53 | 53 | def __str__(self): |
|
54 | 54 | return self.file.url |
@@ -39,9 +39,10 b' def get_viewers():' | |||
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | class AbstractViewer: |
|
42 | def __init__(self, file, file_type): | |
|
42 | def __init__(self, file, file_type, hash): | |
|
43 | 43 | self.file = file |
|
44 | 44 | self.file_type = file_type |
|
45 | self.hash = hash | |
|
45 | 46 | |
|
46 | 47 | @staticmethod |
|
47 | 48 | def supports(file_type): |
@@ -115,6 +116,7 b' class ImageViewer(AbstractViewer):' | |||
|
115 | 116 | return '<a class="{}" href="{full}">' \ |
|
116 | 117 | '<img class="post-image-preview"' \ |
|
117 | 118 | ' src="{}"' \ |
|
119 | ' alt="{}"' \ | |
|
118 | 120 | ' width="{}"' \ |
|
119 | 121 | ' height="{}"' \ |
|
120 | 122 | ' data-width="{}"' \ |
@@ -122,6 +124,7 b' class ImageViewer(AbstractViewer):' | |||
|
122 | 124 | '</a>' \ |
|
123 | 125 | .format(CSS_CLASS_THUMB, |
|
124 | 126 | thumb_url, |
|
127 | self.hash, | |
|
125 | 128 | str(pre_width), |
|
126 | 129 | str(pre_height), str(width), str(height), |
|
127 | 130 | full=self.file.url, image_meta=metadata) |
General Comments 0
You need to be logged in to leave comments.
Login now