Commit 78505444 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Make sure that 0 is returned when a preference is not set.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20878 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5d29f58d
...@@ -469,18 +469,18 @@ class Image(File, OFSImage): ...@@ -469,18 +469,18 @@ class Image(File, OFSImage):
security.declareProtected('View', 'getSizeFromImageDisplay') security.declareProtected('View', 'getSizeFromImageDisplay')
def getSizeFromImageDisplay(self, image_display): def getSizeFromImageDisplay(self, image_display):
"""Retuns the size for this image display, or None if this image display name
is not known.
""" """
preference_tool = self.getPortalObject().portal_preferences Return the size for this image display, or None if this image display name
default_displays = dict() is not known. If the preference is not set, (0, 0) is returned.
for id in default_displays_id_list: """
height_preference = 'preferred_%s_image_height' % (id) if image_display in default_displays_id_list:
width_preferece = 'preferred_%s_image_width' % (id) preference_tool = self.getPortalObject().portal_preferences
image_size = (preference_tool.getPreference(height_preference), height_preference = 'preferred_%s_image_height' % (image_display,)
preference_tool.getPreference(width_preferece)) width_preferece = 'preferred_%s_image_width' % (image_display,)
default_displays.setdefault(id, image_size) height = preference_tool.getPreference(height_preference, 0)
return default_displays.get(image_display, None) width = preference_tool.getPreference(width_preferece, 0)
return (height, width)
return None
# #
# FTP/WebDAV support # FTP/WebDAV support
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment