Skip to content

Commit

Permalink
Fixed getting original data for a tile.
Browse files Browse the repository at this point in the history
Fixes #64
  • Loading branch information
mauritsvanrees committed Jul 14, 2022
1 parent dabc84d commit 0f7168c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
2 changes: 2 additions & 0 deletions news/64.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed getting original data for a tile.
[maurits]
26 changes: 10 additions & 16 deletions plone/scale/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ def pre_scale(self, **parameters):
# There is nothing we can do.
return
fieldname = parameters.get("fieldname", None)
if scaling_factory.get_original_value(fieldname=fieldname) is None:
field = scaling_factory.get_original_value(fieldname=fieldname)
if field is None:
# Either an empty field, or the field does not exist.
return

Expand All @@ -238,21 +239,14 @@ def pre_scale(self, **parameters):
# Start with a basis.
width = parameters.get("width")
height = parameters.get("height")
mimetype = ""
if "fieldname" in parameters:
# We should get this in a different way probably.
field = getattr(self.context, parameters["fieldname"], None)
if field:
orig_width, orig_height = field.getImageSize()
mode = get_scale_mode(
parameters.get("direction") or parameters.get("mode") or "contain"
)
width, height = calculate_scaled_dimensions(
orig_width, orig_height, width, height, mode
)
mimetype = field.contentType
if not (width and height):
width = height = 400
orig_width, orig_height = field.getImageSize()
mode = get_scale_mode(
parameters.get("direction") or parameters.get("mode") or "contain"
)
width, height = calculate_scaled_dimensions(
orig_width, orig_height, width, height, mode
)
mimetype = field.contentType
key = self.hash(**parameters)
info = dict(
uid=uid,
Expand Down

0 comments on commit 0f7168c

Please sign in to comment.