##// END OF EJS Templates
Different images for different URL protocols
neko259 -
r1677:ccb8591c default
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -3,7 +3,7 b' from django.template.defaultfilters impo'
3 from django.contrib.staticfiles.templatetags.staticfiles import static
3 from django.contrib.staticfiles.templatetags.staticfiles import static
4
4
5 FILE_STUB_IMAGE = 'images/file.png'
5 FILE_STUB_IMAGE = 'images/file.png'
6 FILE_STUB_URL = 'images/url.png'
6 FILE_STUB_URL = 'url'
7
7
8 FILE_TYPES_VIDEO = (
8 FILE_TYPES_VIDEO = (
9 'webm',
9 'webm',
@@ -33,6 +33,10 b' PLAIN_FILE_FORMATS = {'
33 'xcf': 'xcf',
33 'xcf': 'xcf',
34 }
34 }
35
35
36 URL_PROTOCOLS = {
37 'magnet': 'magnet',
38 }
39
36 CSS_CLASS_IMAGE = 'image'
40 CSS_CLASS_IMAGE = 'image'
37 CSS_CLASS_THUMB = 'thumb'
41 CSS_CLASS_THUMB = 'thumb'
38
42
@@ -143,7 +147,12 b' class UrlViewer(AbstractViewer):'
143 return '<div class="image">' \
147 return '<div class="image">' \
144 '{}' \
148 '{}' \
145 '</div>'.format(self.get_format_view())
149 '</div>'.format(self.get_format_view())
150
146 def get_format_view(self):
151 def get_format_view(self):
152 protocol = self.url.split('://')[0]
153 url_image_name = URL_PROTOCOLS.get(protocol, FILE_STUB_URL)
154 image = static('images/' + url_image_name + '.png')
155
147 return '<a href="{}">' \
156 return '<a href="{}">' \
148 '<img class="url-image" src="{}" width="200" height="150"/>' \
157 '<img class="url-image" src="{}" width="200" height="150"/>' \
149 '</a>'.format(self.url, static(FILE_STUB_URL))
158 '</a>'.format(self.url, image)
General Comments 0
You need to be logged in to leave comments. Login now