From 20afca608cb7d9aee2a25f07da526af564a963aa Mon Sep 17 00:00:00 2001 From: Andre D Date: Wed, 26 Oct 2011 23:30:55 -0400 Subject: [PATCH] Corrected an issue where thumbnails had the wrong size. --- r2/r2/models/link.py | 13 ++++++++++++- r2/r2/templates/link.html | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index 9153a8e26..af9c8163f 100644 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -370,21 +370,32 @@ class Link(Thing, Printable): item.over_18 = bool(item.over_18 or item.subreddit.over_18 or item.nsfw_str) item.nsfw = item.over_18 and user.pref_label_nsfw - + + item.rendered_thumbnail_size = (70, 50) + item.is_author = (user == item.author) # always show a promo author their own thumbnail if item.promoted and (user_is_admin or item.is_author) and item.has_thumbnail: item.thumbnail = media.thumbnail_url(item) + if(hasattr(item, 'thumbnail_size')): + item.rendered_thumbnail_size = item.thumbnail_size + else: + item.rendered_thumbnail_size = None elif user.pref_no_profanity and item.over_18 and not c.site.over_18: if show_media: item.thumbnail = "/static/nsfw2.png" + item.rendered_thumbnail_size = (70, 70) else: item.thumbnail = "" elif not show_media: item.thumbnail = "" elif item.has_thumbnail: item.thumbnail = media.thumbnail_url(item) + if hasattr(item, 'thumbnail_size'): + item.rendered_thumbnail_size = item.thumbnail_size + else: + item.rendered_thumbnail_size = None elif item.is_self: item.thumbnail = g.self_thumb else: diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html index 2fb2d988d..62453d64d 100644 --- a/r2/r2/templates/link.html +++ b/r2/r2/templates/link.html @@ -235,10 +235,10 @@ ${parent.thing_css_class(what)} ${"over18" if thing.over_18 else ""} <%call expr="make_link('thumbnail', 'thumbnail')"> ​ <% - if not hasattr(thing, 'thumbnail_size'): + if not hasattr(thing, 'rendered_thumbnail_size') or thing.rendered_thumbnail_size is None: size_str = "" else: - size_str = "width = '%d' height = '%d'" % (thing.thumbnail_size[0], thing.thumbnail_size[1]) + size_str = "width='%d' height='%d'" % (thing.rendered_thumbnail_size[0], thing.rendered_thumbnail_size[1]) %>