()
| 18 | } |
| 19 | |
| 20 | createMedia() { |
| 21 | var self = this, |
| 22 | image_class = "tl-media-item tl-media-image tl-media-shadow"; |
| 23 | |
| 24 | if (this.data.url.match(/.png(\?.*)?$/) || this.data.url.match(/.svg(\?.*)?$/)) { |
| 25 | image_class = "tl-media-item tl-media-image" |
| 26 | } |
| 27 | |
| 28 | this._el.content_item = this.domCreate("img", image_class, this._el.content); |
| 29 | |
| 30 | if (this.data.alt) { |
| 31 | this._el.content_item.alt = this.data.alt; |
| 32 | } else if (this.data.caption) { |
| 33 | this._el.content_item.alt = unhtmlify(this.data.caption); |
| 34 | } |
| 35 | |
| 36 | if (this.data.title) { |
| 37 | this._el.content_item.title = this.data.title; |
| 38 | } else if (this.data.caption) { |
| 39 | this._el.content_item.title = unhtmlify(this.data.caption); |
| 40 | } |
| 41 | |
| 42 | // Media Loaded Event |
| 43 | this._el.content_item.addEventListener('load', function(e) { |
| 44 | self.onMediaLoaded(); |
| 45 | }); |
| 46 | |
| 47 | this._el.content_item.src = this.getImageURL(); |
| 48 | } |
| 49 | |
| 50 | getImageURL(w, h) { |
| 51 | return transformMediaURL(this.data.url); |
no test coverage detected