mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-21 21:41:55 +00:00
Fixed ".." appearing in rendition filenames
Happened when there was no cache key
This commit is contained in:
parent
f81385da31
commit
0d935dac02
2 changed files with 40 additions and 1 deletions
|
|
@ -195,7 +195,10 @@ class AbstractImage(models.Model, TagSearchable):
|
|||
'gif': '.gif',
|
||||
}
|
||||
|
||||
output_extension = '.'.join([vary_key, filter.spec]) + FORMAT_EXTENSIONS[output_format]
|
||||
output_extension = filter.spec + FORMAT_EXTENSIONS[output_format]
|
||||
if vary_key:
|
||||
output_extension = vary_key + '.' + output_extension
|
||||
|
||||
output_filename_without_extension = input_filename_without_extension[:(59 - len(output_extension))] # Truncate filename to prevent it going over 60 chars
|
||||
output_filename = output_filename_without_extension + '.' + output_extension
|
||||
|
||||
|
|
|
|||
|
|
@ -325,3 +325,39 @@ class TestGetImageForm(TestCase, WagtailTestUtils):
|
|||
self.assertIsInstance(form.base_fields['focal_point_y'].widget, forms.HiddenInput)
|
||||
self.assertIsInstance(form.base_fields['focal_point_width'].widget, forms.HiddenInput)
|
||||
self.assertIsInstance(form.base_fields['focal_point_height'].widget, forms.HiddenInput)
|
||||
|
||||
|
||||
class TestRenditionFilenames(TestCase):
|
||||
# Can't create image in setUp as we need a unique filename for each test.
|
||||
# This stops Django appending some rubbish to the filename which makes
|
||||
# the assertions difficult.
|
||||
|
||||
def test_normal_filter(self):
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file(filename='test_rf1.png'),
|
||||
)
|
||||
rendition = image.get_rendition('width-100')
|
||||
|
||||
self.assertEqual(rendition.file.name, 'images/test_rf1.width-100.png')
|
||||
|
||||
def test_fill_filter(self):
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file(filename='test_rf2.png'),
|
||||
)
|
||||
rendition = image.get_rendition('fill-100x100')
|
||||
|
||||
self.assertEqual(rendition.file.name, 'images/test_rf2.2e16d0ba.fill-100x100.png')
|
||||
|
||||
def test_fill_filter_with_focal_point(self):
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file(filename='test_rf3.png'),
|
||||
)
|
||||
image.set_focal_point(Rect(100, 100, 200, 200))
|
||||
image.save()
|
||||
|
||||
rendition = image.get_rendition('fill-100x100')
|
||||
|
||||
self.assertEqual(rendition.file.name, 'images/test_rf3.15ee4958.fill-100x100.png')
|
||||
|
|
|
|||
Loading…
Reference in a new issue