Commits

Walter Dörwald  committed fcda9e0

Bildgrößenberechnung wird nun auch für <input type="image" gemacht.
Das size-Attribut wird auf die Breite gesetzt. Ein Höhenattribut gibt
es nicht.

  • Participants
  • Parent commits 0ca758d

Comments (0)

Files changed (3)

 	Old method: e = html.div(html.img(...),gurk.hurz()).asHTML().asString()
 	New method: e = html.div(html.img(...),gurk.hurz().asHTML()).asString()
 
+Image size calculation is now done for <input type="image">. The "size" attribute
+is set to the image width.
+
 New in 0.3.4
 ------------
 

File xist/html.py

 	empty = 1
 	attrHandlers = xsc.appendDict(attrs,{ "type" : xsc.TextAttr , "name" : xsc.TextAttr , "value" : xsc.TextAttr , "checked" : xsc.TextAttr , "disabled" : xsc.TextAttr , "readonly" : xsc.TextAttr , "size" : xsc.TextAttr , "maxlength" : xsc.TextAttr , "src" : xsc.URLAttr , "alt" : xsc.TextAttr , "usemap" : xsc.TextAttr , "tabindex" : xsc.TextAttr , "accesskey" : xsc.TextAttr , "onfocus" : xsc.TextAttr , "onblur" : xsc.TextAttr , "onselect" : xsc.TextAttr , "onchange" : xsc.TextAttr , "accept" : xsc.TextAttr })
 
+	def asString(self,XHTML = None):
+		if self.hasAttr("type") and self["type"].asHTML().asPlainString() == "image":
+			return self._asStringWithImageSize(XHTML,"src","size",None) # no height
+		else:
+			return xsc.Element.asString(self,XHTML)
+
 class button(xsc.Element):
 	"""
 	push button
 					v.append(value.asString(XHTML))
 				v.append('"')
 		if size is not None:
-			if not self.hasAttr(widthattr):
+			if widthattr is not None and not self.hasAttr(widthattr):
 				v.append(' ')
 				v.append(widthattr)
 				v.append('="')
 				v.append(str(size[0]))
 				v.append('"')
-		if not self.hasAttr(heightattr):
+			if heightattr is not None and not self.hasAttr(heightattr):
 				v.append(' ')
 				v.append(heightattr)
 				v.append('="')