kopia lustrzana https://github.com/wagtail/wagtail
Replaced get_vary with vary_fields
rodzic
577183ba89
commit
3b37a52a25
|
@ -38,6 +38,8 @@ class DoNothingOperation(Operation):
|
|||
|
||||
|
||||
class FillOperation(Operation):
|
||||
vary_fields = ('focal_point_width', 'focal_point_height', 'focal_point_x', 'focal_point_y')
|
||||
|
||||
def construct(self, size, *extra):
|
||||
# Get width and height
|
||||
width_str, height_str = size.split('x')
|
||||
|
@ -175,21 +177,6 @@ class FillOperation(Operation):
|
|||
|
||||
willow.resize(width, height)
|
||||
|
||||
def get_vary(self, image):
|
||||
focal_point = image.get_focal_point()
|
||||
|
||||
if focal_point is not None:
|
||||
focal_point_key = "%(x)d-%(y)d-%(width)dx%(height)d" % {
|
||||
'x': int(focal_point.centroid_x),
|
||||
'y': int(focal_point.centroid_y),
|
||||
'width': int(focal_point.width),
|
||||
'height': int(focal_point.height),
|
||||
}
|
||||
else:
|
||||
focal_point_key = ''
|
||||
|
||||
return [focal_point_key]
|
||||
|
||||
|
||||
class MinMaxOperation(Operation):
|
||||
def construct(self, size):
|
||||
|
|
|
@ -302,8 +302,10 @@ class Filter(models.Model):
|
|||
vary = []
|
||||
|
||||
for operation in self.operations:
|
||||
if hasattr(operation, 'get_vary'):
|
||||
vary.extend(operation.get_vary(image))
|
||||
for field in getattr(operation, 'vary_fields', []):
|
||||
value = getattr(image, field)
|
||||
if value is not None:
|
||||
vary.append(str(value))
|
||||
|
||||
return vary
|
||||
|
||||
|
|
|
@ -347,4 +347,4 @@ class TestVaryKey(unittest.TestCase):
|
|||
fil = Filter(spec='fill-100x100')
|
||||
vary_key = fil.get_vary_key(image)
|
||||
|
||||
self.assertEqual(vary_key, 'fa9841ef')
|
||||
self.assertEqual(vary_key, '0bbe3b2f')
|
||||
|
|
Ładowanie…
Reference in New Issue