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.
""" """
Return the size for this image display, or None if this image display name
is not known. If the preference is not set, (0, 0) is returned.
"""
if image_display in default_displays_id_list:
preference_tool = self.getPortalObject().portal_preferences preference_tool = self.getPortalObject().portal_preferences
default_displays = dict() height_preference = 'preferred_%s_image_height' % (image_display,)
for id in default_displays_id_list: width_preferece = 'preferred_%s_image_width' % (image_display,)
height_preference = 'preferred_%s_image_height' % (id) height = preference_tool.getPreference(height_preference, 0)
width_preferece = 'preferred_%s_image_width' % (id) width = preference_tool.getPreference(width_preferece, 0)
image_size = (preference_tool.getPreference(height_preference), return (height, width)
preference_tool.getPreference(width_preferece)) return None
default_displays.setdefault(id, image_size)
return default_displays.get(image_display, 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