Image Columns
Image columns allow you to render an image of your choice within the table. By default, the image column will use the value stored in the underlying struct to fetch the image content.
You can create an image column as so:
go
ImageColumn("my-image")Path
The path method allows you set the path to fetch the image from. This value is directly injected into a <img/> tag's src method.
go
// static
ImageColumn("selfie").
Path("/images/my-selfie.png") // A local path
Path("https://<your-url>/my-selfie.png") // A remote path
// callback
ImageColumn("selfie").
PathFn(
func (ctx CellContext) string {
return "/images/my-selfie.png"
}
)Alt Path
You can specifc the alt method on an image tag using the AltPath method:
go
// static
ImageColumn("selfie").
AltPath("/image/my-alternative-selife.png")
// callback
ImageColumn("selfie").
AltPathFn(
func (ctx CellContext) string {
return "/image/my-alternative-selife.png"
}
)Rounded
You can specify if the image should be rounded (default is square) with the Rounded method:
go
// static
ImageColumn("selife").
Rounded()
// callback
ImageColumn("selfie").
RoundedFn(
func (ctx CellContext) bool {
return true
}
)More Control
If you need more control over how your image is rendered, please see our attributes section.