github.com/kotovmak/go-admin@v1.1.1/template/components/image.go (about) 1 package components 2 3 import ( 4 "html/template" 5 6 "github.com/kotovmak/go-admin/plugins/admin/modules" 7 "github.com/kotovmak/go-admin/template/types" 8 ) 9 10 type ImgAttribute struct { 11 Name string 12 Width string 13 Height string 14 Uuid string 15 HasModal bool 16 Src template.URL 17 types.Attribute 18 } 19 20 func (compo *ImgAttribute) SetWidth(value string) types.ImgAttribute { 21 compo.Width = value 22 return compo 23 } 24 25 func (compo *ImgAttribute) SetHeight(value string) types.ImgAttribute { 26 compo.Height = value 27 return compo 28 } 29 30 func (compo *ImgAttribute) WithModal() types.ImgAttribute { 31 compo.HasModal = true 32 compo.Uuid = modules.Uuid() 33 return compo 34 } 35 36 func (compo *ImgAttribute) SetSrc(value template.HTML) types.ImgAttribute { 37 compo.Src = template.URL(value) 38 return compo 39 } 40 41 func (compo *ImgAttribute) GetContent() template.HTML { 42 return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "image") 43 }