@@ -18,6 +18,13 @@ class Attachment {
1818 */
1919 protected $ text ;
2020
21+ /**
22+ * Optional image that should appear within the attachment
23+ *
24+ * @var string
25+ */
26+ protected $ image_url ;
27+
2128 /**
2229 * Optional text that should appear above the formatted data
2330 *
@@ -59,6 +66,8 @@ public function __construct(array $attributes)
5966
6067 if (isset ($ attributes ['text ' ])) $ this ->setText ($ attributes ['text ' ]);
6168
69+ if (isset ($ attributes ['image_url ' ])) $ this ->setImageUrl ($ attributes ['image_url ' ]);
70+
6271 if (isset ($ attributes ['pretext ' ])) $ this ->setPretext ($ attributes ['pretext ' ]);
6372
6473 if (isset ($ attributes ['color ' ])) $ this ->setColor ($ attributes ['color ' ]);
@@ -114,6 +123,29 @@ public function setText($text)
114123 return $ this ;
115124 }
116125
126+ /**
127+ * Get the optional image to appear within the attachment
128+ *
129+ * @return string
130+ */
131+ public function getImageUrl ()
132+ {
133+ return $ this ->image_url ;
134+ }
135+
136+ /**
137+ * Set the optional image to appear within the attachment
138+ *
139+ * @param string $image_url
140+ * @return $this
141+ */
142+ public function setImageUrl ($ image_url )
143+ {
144+ $ this ->image_url = $ image_url ;
145+
146+ return $ this ;
147+ }
148+
117149 /**
118150 * Get the text that should appear above the formatted data
119151 *
@@ -262,7 +294,8 @@ public function toArray()
262294 'text ' => $ this ->getText (),
263295 'pretext ' => $ this ->getPretext (),
264296 'color ' => $ this ->getColor (),
265- 'mrkdwn_in ' => $ this ->getMarkdownFields ()
297+ 'mrkdwn_in ' => $ this ->getMarkdownFields (),
298+ 'image_url ' => $ this ->getImageUrl ()
266299 ];
267300
268301 $ data ['fields ' ] = $ this ->getFieldsAsArrays ();
0 commit comments