kopia lustrzana https://github.com/wagtail/wagtail
Removed focal_point parameter from get_rendition
rodzic
3d0bd3dfbd
commit
44ef57a6f0
|
@ -117,19 +117,17 @@ class AbstractImage(models.Model, TagSearchable):
|
||||||
|
|
||||||
return focal_point
|
return focal_point
|
||||||
|
|
||||||
def get_rendition(self, filter, focal_point=None):
|
def get_rendition(self, filter):
|
||||||
focal_point = focal_point or self.focal_point
|
|
||||||
|
|
||||||
if not hasattr(filter, 'process_image'):
|
if not hasattr(filter, 'process_image'):
|
||||||
# assume we've been passed a filter spec string, rather than a Filter object
|
# assume we've been passed a filter spec string, rather than a Filter object
|
||||||
# TODO: keep an in-memory cache of filters, to avoid a db lookup
|
# TODO: keep an in-memory cache of filters, to avoid a db lookup
|
||||||
filter, created = Filter.objects.get_or_create(spec=filter)
|
filter, created = Filter.objects.get_or_create(spec=filter)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if focal_point:
|
if self.focal_point:
|
||||||
rendition = self.renditions.get(
|
rendition = self.renditions.get(
|
||||||
filter=filter,
|
filter=filter,
|
||||||
focal_point_key=focal_point.get_key(),
|
focal_point_key=self.focal_point.get_key(),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
rendition = self.renditions.get(
|
rendition = self.renditions.get(
|
||||||
|
@ -142,12 +140,12 @@ class AbstractImage(models.Model, TagSearchable):
|
||||||
# If we have a backend attribute then pass it to process
|
# If we have a backend attribute then pass it to process
|
||||||
# image - else pass 'default'
|
# image - else pass 'default'
|
||||||
backend_name = getattr(self, 'backend', 'default')
|
backend_name = getattr(self, 'backend', 'default')
|
||||||
generated_image_file = filter.process_image(file_field.file, focal_point=focal_point, backend_name=backend_name)
|
generated_image_file = filter.process_image(file_field.file, focal_point=self.focal_point, backend_name=backend_name)
|
||||||
|
|
||||||
if focal_point:
|
if self.focal_point:
|
||||||
rendition, created = self.renditions.get_or_create(
|
rendition, created = self.renditions.get_or_create(
|
||||||
filter=filter,
|
filter=filter,
|
||||||
focal_point_key=focal_point.get_key(),
|
focal_point_key=self.focal_point.get_key(),
|
||||||
defaults={'file': generated_image_file}
|
defaults={'file': generated_image_file}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
Ładowanie…
Reference in New Issue