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