Commit 793edb8b authored by 's avatar

Merged new defaults for alt and border attrs

parent ba536eed
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Image object""" """Image object"""
__version__='$Revision: 1.114 $'[11:-2] __version__='$Revision: 1.115 $'[11:-2]
import Globals, string, struct, content_types import Globals, string, struct, content_types
from OFS.content_types import guess_content_type from OFS.content_types import guess_content_type
...@@ -239,13 +239,6 @@ class File(Persistent,Implicit,PropertyManager, ...@@ -239,13 +239,6 @@ class File(Persistent,Implicit,PropertyManager,
data=data.next data=data.next
return '' return ''
def __call__(self):
# allow publisher to call the object directly - this lets File
# and Image objects act as the default document if they want.
request=self.REQUEST
response=request.RESPONSE
return self.index_html(request, response)
def view_image_or_file(self, URL1): def view_image_or_file(self, URL1):
""" """
...@@ -561,12 +554,7 @@ class Image(File): ...@@ -561,12 +554,7 @@ class Image(File):
def __str__(self): def __str__(self):
width=self.width and ('width="%s" ' % self.width) or '' return self.tag()
height=self.height and ('height="%s" ' % self.height) or ''
return '<img src="%s" %s%salt="%s">' % (
self.absolute_url(), width, height, self.title_or_id()
)
def tag(self, height=None, width=None, alt=None, def tag(self, height=None, width=None, alt=None,
scale=0, xscale=0, yscale=0, **args): scale=0, xscale=0, yscale=0, **args):
...@@ -585,29 +573,32 @@ class Image(File): ...@@ -585,29 +573,32 @@ class Image(File):
# Auto-scaling support # Auto-scaling support
xdelta = xscale or scale xdelta = xscale or scale
ydelta = yscale or scale ydelta = yscale or scale
if xdelta and width != None:
if xdelta and width:
width = str(int(width) * xdelta) width = str(int(width) * xdelta)
if ydelta and height != None: if ydelta and height:
height = str(int(height) * ydelta) height = str(int(height) * ydelta)
string='<img src="%s"' % (self.absolute_url()) result='<img src="%s"' % (self.absolute_url())
if alt is None: if alt is None:
alt=self.title_or_id() alt=getattr(self, 'title', '')
if alt: result = '%s alt="%s"' % (result, alt)
string = '%s alt="%s"' % (string, alt)
if height: if height:
string = '%s height="%s"' % (string, height) result = '%s height="%s"' % (result, height)
if width: if width:
string = '%s width="%s"' % (string, width) result = '%s width="%s"' % (result, width)
if not 'border' in map(string.lower, args.keys()):
result = '%s border="0"' % result
for key in args.keys(): for key in args.keys():
value = args.get(key) value = args.get(key)
string = '%s %s="%s"' % (string, key, value) result = '%s %s="%s"' % (result, key, value)
return string + '>' return '%s>' % result
def cookId(id, title, file): def cookId(id, title, file):
......
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