MCPcopy
hub / github.com/NUKnightLab/TimelineJS3 / createMedia

Method createMedia

src/js/media/types/Image.js:20–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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);

Callers 1

_loadMediaMethod · 0.95

Calls 5

getImageURLMethod · 0.95
unhtmlifyFunction · 0.90
domCreateMethod · 0.80
addEventListenerMethod · 0.80
onMediaLoadedMethod · 0.80

Tested by

no test coverage detected