diff --git a/src/layer/ImageOverlay.js b/src/layer/ImageOverlay.js index b1bc10ba..e8903787 100644 --- a/src/layer/ImageOverlay.js +++ b/src/layer/ImageOverlay.js @@ -179,9 +179,12 @@ export var ImageOverlay = Layer.extend({ }, _initImage: function () { - var img = this._image = DomUtil.create('img', - 'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated ' : '') + - (this.options.className || '')); + var wasElementSupplied = this._url.tagName === 'IMG'; + var img = this._image = wasElementSupplied ? this._url : DomUtil.create('img'); + + DomUtil.addClass(img, 'leaflet-image-layer'); + if (this._zoomAnimated) { DomUtil.addClass(img, 'leaflet-zoom-animated'); } + if (this.options.className) { DomUtil.addClass(img, this.options.className); } img.onselectstart = Util.falseFn; img.onmousemove = Util.falseFn; @@ -199,6 +202,8 @@ export var ImageOverlay = Layer.extend({ this._updateZIndex(); } + if (wasElementSupplied) { return; } + img.src = this._url; img.alt = this.options.alt; },