Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
cfe7d281
Commit
cfe7d281
authored
Apr 12, 2001
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged fix to add 'css_class' to Image.tag() to work around 'class' being
a Python reserved word.
parent
4130f24e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
lib/python/OFS/Image.py
lib/python/OFS/Image.py
+11
-2
No files found.
lib/python/OFS/Image.py
View file @
cfe7d281
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Image object"""
__version__
=
'$Revision: 1.12
7
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.12
8
$'
[
11
:
-
2
]
import
Globals
,
string
,
struct
,
content_types
from
OFS.content_types
import
guess_content_type
...
...
@@ -589,7 +589,7 @@ class Image(File):
return
self
.
tag
()
def
tag
(
self
,
height
=
None
,
width
=
None
,
alt
=
None
,
scale
=
0
,
xscale
=
0
,
yscale
=
0
,
**
args
):
scale
=
0
,
xscale
=
0
,
yscale
=
0
,
css_class
=
None
,
**
args
):
"""
Generate an HTML IMG tag for this image, with customization.
Arguments to self.tag() can be any valid attributes of an IMG tag.
...
...
@@ -598,6 +598,12 @@ class Image(File):
'height', 'width', and 'alt'. If specified, the 'scale', 'xscale',
and 'yscale' keyword arguments will be used to automatically adjust
the output height and width values of the image tag.
Since 'class' is a Python reserved word, it cannot be passed in
directly in keyword arguments which is a problem if you are
trying to use 'tag()' to include a CSS class. The tag() method
will accept a 'css_class' argument that will be converted to
'class' in the output tag to work around this.
"""
if
height
is
None
:
height
=
self
.
height
if
width
is
None
:
width
=
self
.
width
...
...
@@ -626,6 +632,9 @@ class Image(File):
if
not
'border'
in
map
(
string
.
lower
,
args
.
keys
()):
result
=
'%s border="0"'
%
result
if
css_class
is
not
None
:
result
=
'%s class="%s"'
%
(
result
,
css_class
)
for
key
in
args
.
keys
():
value
=
args
.
get
(
key
)
result
=
'%s %s="%s"'
%
(
result
,
key
,
value
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment