From 8718ba36644b75bbee2d9cccd4ec9477b4b315fd Mon Sep 17 00:00:00 2001 From: Duncan Lock Date: Wed, 1 May 2013 18:42:03 -0700 Subject: [PATCH] Fixed the responsive styles so they work properly with small, as well as large images --- .../better_figures_and_images.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/better_figures_and_images/better_figures_and_images.py b/better_figures_and_images/better_figures_and_images.py index af73104..40737f2 100644 --- a/better_figures_and_images/better_figures_and_images.py +++ b/better_figures_and_images/better_figures_and_images.py @@ -39,14 +39,14 @@ def content_object_init(instance): if 'img' in content: for img in soup('img'): + # TODO: Pretty sure this isn't the right way to do this, too hard coded. + # There must be a setting that I should be using? + src = instance.settings['PATH'] + '/images/' + os.path.split(img['src'])[1] + im = Image.open(src) + extra_style = 'width: {}px; height: auto;'.format(im.size[0]) + if instance.settings['RESPONSIVE_IMAGES']: - extra_style = 'max-width: 100%; height: auto;' - else: - # TODO: Pretty sure this isn't the right way to do this, too hard coded. - # There must be a setting that I should be using? - src = instance.settings['PATH'] + '/images/' + os.path.split(img['src'])[1] - im = Image.open(src) - extra_style = 'width: {}px; height: auto;'.format(im.size[0]) + extra_style += ' max-width: 100%;' if img.get('style'): img['style'] += extra_style