Commit 0b7e1138 authored by Fabien Morin's avatar Fabien Morin

use the real width and height of the image data

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32868 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3506a84b
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
from Products.Formulator import Widget, Validator from Products.Formulator import Widget, Validator
from Products.Formulator.Field import ZMIField from Products.Formulator.Field import ZMIField
from Products.Formulator.DummyField import fields from Products.Formulator.DummyField import fields
from OFS.Image import Image as OFSImage
from lxml.etree import Element from lxml.etree import Element
from Acquisition import aq_base from Acquisition import aq_base
from lxml import etree from lxml import etree
...@@ -135,6 +136,12 @@ class ImageFieldWidget(Widget.TextWidget): ...@@ -135,6 +136,12 @@ class ImageFieldWidget(Widget.TextWidget):
# is displayed in the form as a thumbnail, it will be added in the odg # is displayed in the form as a thumbnail, it will be added in the odg
# document as thumbnail size/quality # document as thumbnail size/quality
content_type, image_data = image_object.convert(**image_parameter_dict) content_type, image_data = image_object.convert(**image_parameter_dict)
if isinstance(image_data, str):
image = OFSImage('', '', image_data)
else:
image = image_data
width = image.width
height = image.height
if image_data is None: if image_data is None:
return draw_frame_node return draw_frame_node
...@@ -154,7 +161,10 @@ class ImageFieldWidget(Widget.TextWidget): ...@@ -154,7 +161,10 @@ class ImageFieldWidget(Widget.TextWidget):
# set the size of the image # set the size of the image
if display is not None: if display is not None:
width, height = image_object.getSizeFromImageDisplay(display) # if the image width and height are not on defined, use current
# width and height
if (image_object.getWidth(), image_object.getHeight()) not in \
((-1, -1), (0,0)):
width, height = image_object._getAspectRatioSize(width, height) width, height = image_object._getAspectRatioSize(width, height)
if draw_frame_node.attrib.get('{%s}width' % SVG_URI, {}) != {} and \ if draw_frame_node.attrib.get('{%s}width' % SVG_URI, {}) != {} and \
draw_frame_node.attrib.get('{%s}height' % SVG_URI, {}) != {}: draw_frame_node.attrib.get('{%s}height' % SVG_URI, {}) != {}:
......
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