| 1 | package slack |
| 2 | |
| 3 | // ImageBlock defines data required to display an image as a block element |
| 4 | // |
| 5 | // More Information: https://api.slack.com/reference/messaging/blocks#image |
| 6 | type ImageBlock struct { |
| 7 | Type MessageBlockType `json:"type"` |
| 8 | ImageURL string `json:"image_url"` |
| 9 | AltText string `json:"alt_text"` |
| 10 | BlockID string `json:"block_id,omitempty"` |
| 11 | Title *TextBlockObject `json:"title,omitempty"` |
| 12 | } |
| 13 | |
| 14 | // BlockType returns the type of the block |
| 15 | func (s ImageBlock) BlockType() MessageBlockType { |
| 16 | return s.Type |
| 17 | } |
| 18 | |
| 19 | // NewImageBlock returns an instance of a new Image Block type |
| 20 | func NewImageBlock(imageURL, altText, blockID string, title *TextBlockObject) *ImageBlock { |
| 21 | return &ImageBlock{ |
| 22 | Type: MBTImage, |
| 23 | ImageURL: imageURL, |
| 24 | AltText: altText, |
| 25 | BlockID: blockID, |
| 26 | Title: title, |
| 27 | } |
| 28 | } |