macro_rules! telegram_image {
($doc:expr, $src:expr $(, class = $class:expr)? $(, alt = $alt:expr)? $(, $attr:literal = $value:expr)* $(,)?) => { ... };
}Available on crate feature
macros only.Expand description
Create an <img> element.
Generates a web_sys::HtmlImageElement with the provided src, optional
CSS class, alt text and additional attributes. Like
telegram_button!, this macro yields a Result for ergonomic error
propagation.
§Examples
ⓘ
use telegram_webapp_sdk::telegram_image;
use wasm_bindgen::JsValue;
let document = web_sys::window()
.and_then(|w| w.document())
.ok_or_else(|| JsValue::from_str("no document"))?;
let image = telegram_image!(document, "/logo.png", class = "logo", alt = "Logo")?;
assert_eq!(image.tag_name(), "IMG");