Commit a01337a3 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

we no longer need to define '__src__' method for Image that returns a '<img src=...>' tag.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39446 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eeb608ed
......@@ -183,71 +183,6 @@ class Image(TextConvertableMixin, File, OFSImage):
else:
return self._baseGetContentType(default)
#
# Photo display methods
#
security.declareProtected(Permissions.View, 'tag')
def tag(self, display=None, height=None, width=None, cookie=0,
alt=None, css_class=None, format=None, quality=_MARKER,
resolution=None, frame=None, **kw):
"""Return HTML img tag."""
self._upradeImage()
# Get cookie if display is not specified.
if display is None:
display = self.REQUEST.cookies.get('display', None)
if quality is _MARKER:
quality = self.getDefaultImageQuality(format)
# display may be set from a cookie.
image_size = self.getSizeFromImageDisplay(display)
convert_kw = dict(format=format, quality=quality, resolution=resolution,
frame=frame, image_size=image_size)
try:
mime, image = self.getConversion(**convert_kw)
except KeyError:
# Generate photo on-the-fly
mime, image = self._makeDisplayPhoto(**convert_kw)
self.setConversion(image, mime, **convert_kw)
width, height = image.width, image.height
# Set cookie for chosen size
if cookie:
self.REQUEST.RESPONSE.setCookie('display', display, path="/")
if display:
result = '<img src="%s?display=%s"' % (self.absolute_url(), display)
else:
result = '<img src="%s"' % (self.absolute_url())
if alt is None:
alt = getattr(self, 'title', '')
if alt == '':
alt = self.getId()
result = '%s alt="%s"' % (result, html_quote(alt))
if height:
result = '%s height="%s"' % (result, height)
if width:
result = '%s width="%s"' % (result, width)
if not 'border' in map(string.lower, kw.keys()):
result = '%s border="0"' % (result)
if css_class is not None:
result = '%s class="%s"' % (result, css_class)
for key in kw.keys():
value = kw.get(key)
result = '%s %s="%s"' % (result, key, value)
result = '%s />' % (result)
return result
def __str__(self):
return self.tag()
security.declareProtected(Permissions.AccessContentsInformation, 'displayIds')
def displayIds(self, exclude=('thumbnail',)):
"""Return list of display Ids."""
......
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