go.talks/pkg/present: fix image size handling.

Fixes golang/go#4527

R=adg
CC=golang-dev
https://golang.org/cl/6933049
diff --git a/pkg/present/image.go b/pkg/present/image.go
index f402e5a..ec859ce 100644
--- a/pkg/present/image.go
+++ b/pkg/present/image.go
@@ -6,7 +6,6 @@
 
 import (
 	"fmt"
-	"html/template"
 	"strings"
 )
 
@@ -15,8 +14,9 @@
 }
 
 type Image struct {
-	URL        string
-	Attributes template.HTML
+	URL    string
+	Width  int
+	Height int
 }
 
 func (i Image) TemplateName() string { return "image" }
@@ -32,8 +32,12 @@
 	case 0:
 		// no size parameters
 	case 2:
-		attr := fmt.Sprintf(`height="%v" width="%v"`, a[0], a[1])
-		img.Attributes = template.HTML(attr)
+		if v, ok := a[0].(int); ok {
+			img.Height = v
+		}
+		if v, ok := a[1].(int); ok {
+			img.Width = v
+		}
 	default:
 		return nil, fmt.Errorf("incorrect image invocation: %q", text)
 	}
diff --git a/present/templates/action.tmpl b/present/templates/action.tmpl
index 8bd0046..a880089 100644
--- a/present/templates/action.tmpl
+++ b/present/templates/action.tmpl
@@ -31,7 +31,11 @@
   <div class="code{{if .Play}} playground{{end}}" contenteditable="true" spellcheck="false">{{.Text}}</div>
 {{end}}
 
-{{define "image"}}<div class="image"><img src="{{.URL}}" {{.Attributes}}></div>{{end}}
+{{define "image"}}
+<div class="image">
+  <img src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}}>
+</div>
+{{end}}
       
 {{define "link"}}<p class="link"><a href="{{.URL}}" target="_blank">{{style .Label}}</a></p>{{end}}