Project

General

Profile

0001-assets-don-t-use-get_thumbnail-on-SVG-files-30533.patch

Frédéric Péters, 11 Feb 2019 04:03 PM

Download (1.69 KB)

View differences:

Subject: [PATCH] assets: don't use get_thumbnail on SVG files (#30533)

 combo/apps/assets/templatetags/assets.py | 2 +-
 tests/test_public_templatetags.py        | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
combo/apps/assets/templatetags/assets.py
52 52
        return ''
53 53

  
54 54
    geometry_string = kwargs.pop('size', None)
55
    if not geometry_string:
55
    if not geometry_string or asset.file.name.endswith('svg'):
56 56
        return asset.url
57 57

  
58 58
    return get_thumbnail(asset, geometry_string, **kwargs).url
tests/test_public_templatetags.py
163 163
        # pass image to sorl.thumbnail
164 164
        t = Template('''{% load assets %}{% asset_url page.picture "collectivity:banner" size="200x200" %}''')
165 165
        assert t.render(Context()).startswith('/media/cache/')
166

  
167
        # unless it's in SVG
168
        page.picture = File(StringIO('test'), 'test2.svg')
169
        page.save()
170
        t = Template('''{% load assets %}{% asset_url page.picture "collectivity:banner" size="200x200" %}''')
171
        assert t.render(Context({'page': page})) == '/media/page-pictures/test2.svg'
166
-