-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.java
More file actions
50 lines (46 loc) · 2.11 KB
/
Copy pathImage.java
File metadata and controls
50 lines (46 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package elements;
import com.slack.api.model.block.Blocks;
import com.slack.api.model.block.SectionBlock;
import com.slack.api.model.block.composition.BlockCompositions;
import com.slack.api.model.block.composition.SlackFileObject;
import com.slack.api.model.block.element.BlockElements;
/**
* Displays an image as part of a larger block of content.
* {@link https://docs.slack.dev/reference/block-kit/block-elements/image-element/}
*/
public class Image {
/**
* A section block with an image accessory using image_url.
*/
public static SectionBlock example01() {
SectionBlock block = Blocks.section(s -> s.blockId("section567")
.text(BlockCompositions.markdownText("This is a section block with an accessory image."))
.accessory(BlockElements.image(
i -> i.imageUrl("https://pbs.twimg.com/profile_images/625633822235693056/lNGUneLX_400x400.jpg")
.altText("cute cat"))));
return block;
}
/**
* An image block using slack_file with a url.
*/
public static SectionBlock example02() {
SectionBlock block = Blocks.section(s -> s.blockId("section567")
.text(BlockCompositions.markdownText("This is a section block with an accessory image."))
.accessory(BlockElements.image(i -> i.slackFile(SlackFileObject.builder()
.url("https://files.slack.com/files-pri/T0123456-F0123456/xyz.png")
.build())
.altText("Slack file object."))));
return block;
}
/**
* An image block using slack_file with a id.
*/
public static SectionBlock example03() {
SectionBlock block = Blocks.section(s -> s.blockId("section567")
.text(BlockCompositions.markdownText("This is a section block with an accessory image."))
.accessory(BlockElements.image(i -> i.slackFile(
SlackFileObject.builder().id("F01234567").build())
.altText("Slack file object."))));
return block;
}
}