Commit c2c6dbc6 authored by Ivan Tyagov's avatar Ivan Tyagov

Resolution was mistakenly used instead of quality so rename accordingly.

Add 'pre_converted_only' to ImageField which is a new way to generate thumbnail URLs
in respect to cache backend.
parent 00bdb44f
......@@ -56,7 +56,7 @@ class ImageFieldWidget(Widget.TextWidget):
The image size is calculated using 'image_display'.
"""
property_names = Widget.TextWidget.property_names + \
['image_display', 'image_format','image_resolution']
['image_display', 'image_format','image_quality', 'image_pre_converted_only']
image_display = fields.StringField('image_display',
title='Image Display',
......@@ -74,13 +74,21 @@ class ImageFieldWidget(Widget.TextWidget):
default='',
required=0)
image_resolution = fields.IntegerField('image_resolution',
title='Image Resolution',
image_quality = fields.IntegerField('image_quality',
title='Image Quality',
description=(
"The resolution used when converting the image. "
"The quality used when converting the image. "
"This is only used with ERP5 Images."),
default=75,
required=0)
image_pre_converted_only = fields.CheckBoxField('image_pre_converted_only',
title='Image Pre Converted Only',
description=(
"Return image only if it is already pre converted in cache. "
"This is only used with ERP5 Images."),
default=False,
required=0)
def render(self, field, key, value, REQUEST, render_prefix=None):
"""Render image field as a link to the image
......@@ -101,7 +109,12 @@ class ImageFieldWidget(Widget.TextWidget):
options = {}
options['display'] = field.get_value('image_display')
options['format'] = field.get_value('image_format')
options['resolution'] = field.get_value('image_resolution')
options['quality'] = field.get_value('image_quality')
pre_converted_only = field.get_value('image_pre_converted_only')
if pre_converted_only:
# only add if it's True as conversion machine assume that if it is missing
# then conversion should happen "on the fly"
options['pre_converted_only'] = pre_converted_only
parameters = '&'.join(['%s=%s' % (k, v) for k, v in options.items() \
if v])
if parameters:
......
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