1 /** 2 * Copyright © DiamondMVC 2019 3 * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE) 4 * Author: Jacob Jensen (bausshf) 5 */ 6 module diamond.web.elements.image; 7 8 import diamond.web.elements.element; 9 10 /// Wrapper around a image. 11 final class Image : Element 12 { 13 private: 14 /// The source. 15 string _source; 16 /// The alt text. 17 string _alt; 18 19 public: 20 final: 21 /// Creates a new image. 22 this() 23 { 24 super("img"); 25 26 alt = ""; 27 } 28 29 /** 30 * Creates a new image. 31 * Params: 32 * source = The source of the image. 33 */ 34 this(string source) 35 { 36 this(); 37 38 this.source = source; 39 } 40 41 @property 42 { 43 /// Gets the source. 44 string source() { return _source; } 45 46 /// Sets the source. 47 void source(string newSource) 48 { 49 _source = newSource; 50 addAttribute("src", _source); 51 } 52 53 /// Gets the alt text. 54 string alt() { return _alt; } 55 56 /// Sets the alt text. 57 void alt(string newAlt) 58 { 59 _alt = newAlt; 60 } 61 } 62 }