Commit 1538070d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

modify ImageField:

* 'image_display' parameter is no longer required. the image will not be resized if this parameter is empty.
* 'resolution' parater is now respected. it was just ignored before.
* creates a shorter URL.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39220 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8759876e
......@@ -32,9 +32,7 @@ from Products.Formulator.Field import ZMIField
from Products.Formulator.DummyField import fields
from OFS.Image import Image as OFSImage
from lxml.etree import Element
from Acquisition import aq_base
from lxml import etree
from decimal import Decimal
import re
DRAW_URI = 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'
......@@ -66,7 +64,7 @@ class ImageFieldWidget(Widget.TextWidget):
"The display size. See ERP5.Document.Image.default_displays_id_list "
"for possible values. This is only used with ERP5 Images."),
default='thumbnail',
required=1)
required=0)
image_format = fields.StringField('image_format',
title='Image Format',
......@@ -100,13 +98,18 @@ class ImageFieldWidget(Widget.TextWidget):
field.get_value('title')
css_class = field.get_value('css_class')
extra = field.get_value('extra')
display = field.get_value('image_display')
format = field.get_value('image_format')
resolution = field.get_value('image_resolution')
options = {}
options['display'] = field.get_value('image_display')
options['format'] = field.get_value('image_format')
options['resolution'] = field.get_value('image_resolution')
parameters = '&'.join(['%s=%s' % (k, v) for k, v in options.items() \
if v])
if parameters:
image = '%s?%s' % (image, parameters)
return Widget.render_element(
"img",
alt=alt,
src="%s?display=%s&format=%s&" % (image, display, format),
src=image,
css_class=css_class,
extra=extra,
)
......
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