diff options
-rw-r--r-- | db.py | 2 | ||||
-rwxr-xr-x | fbin.py | 2 | ||||
-rw-r--r-- | static/no-thumbnail.png | bin | 0 -> 1546 bytes | |||
-rw-r--r-- | templates/images.tmpl | 9 |
4 files changed, 11 insertions, 2 deletions
@@ -67,7 +67,7 @@ class File(Base): return self.get_mime_type().startswith('image') def image_html(self): - return u'<a href="{root}f/{hash}{ext}" title="{filename}"><img src="{root}t/{hash}" alt="{filename}" /></a>'.format( + return u'<a href="{root}f/{hash}{ext}" title="{filename}"><img src="{root}t/{hash}" alt="{filename}" onerror="thumb_onerror(this)" /></a>'.format( root = settings.virtual_root, hash = self.hash, filename = self.filename, ext = os.path.splitext(self.filename)[1]) Base.metadata.create_all() @@ -429,7 +429,7 @@ class Application(object): def static(self, environ, start_response, path): filename = path[1] - if not filename in ('style.css',): + if not filename in ('style.css', 'no-thumbnail.png'): start_response('404 Not Found', []) return [] diff --git a/static/no-thumbnail.png b/static/no-thumbnail.png Binary files differnew file mode 100644 index 0000000..4af3517 --- /dev/null +++ b/static/no-thumbnail.png diff --git a/templates/images.tmpl b/templates/images.tmpl index 4cd3752..1dcfc46 100644 --- a/templates/images.tmpl +++ b/templates/images.tmpl @@ -1,6 +1,15 @@ #def title: images #def header: images #extends templates.base +#def head +<script type="text/javascript"> + function thumb_onerror(img) { + var no_thumb = '${root}s/no-thumbnail.png'; + if(img.src != no_thumb) + img.src = no_thumb; + } +</script> +#end def #def content <p>You have $len($files) uploaded images totaling $total_size.</p> <ul class="image-list"> |