Class: Slack::BlockKit::Element::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/block_kit/element/image.rb

Overview

An element to insert an image - this element can be used in section and context blocks only. If you want a block with only an image in it, you’re looking for the image block. (Slack::BlockKit::Layout::Image)

api.slack.com/reference/messaging/block-elements#image

Constant Summary collapse

TYPE =
'image'

Instance Method Summary collapse

Constructor Details

#initialize(image_url:, alt_text:) ⇒ Image

Returns a new instance of Image.



14
15
16
17
# File 'lib/slack/block_kit/element/image.rb', line 14

def initialize(image_url:, alt_text:)
  @image_url = image_url
  @alt_text = alt_text
end

Instance Method Details

#as_jsonObject



19
20
21
22
23
24
25
# File 'lib/slack/block_kit/element/image.rb', line 19

def as_json(*)
  {
    type: TYPE,
    image_url: @image_url,
    alt_text: @alt_text
  }
end