Img: allow for data urls

This commit is contained in:
Thomas Gelf 2018-02-20 14:39:58 +01:00
parent 5a5cd9ba1e
commit 0ae1ed1319
1 changed files with 11 additions and 2 deletions

View File

@ -45,7 +45,12 @@ class Img extends BaseElement
$this->url = $url; $this->url = $url;
} else { } else {
if ($urlParams === null) { if ($urlParams === null) {
$this->url = Url::fromPath($url); if (is_string($url) && substr($url, 0, 5) === 'data:') {
$this->url = $url;
return;
} else {
$this->url = Url::fromPath($url);
}
} else { } else {
$this->url = Url::fromPath($url, $urlParams); $this->url = Url::fromPath($url, $urlParams);
} }
@ -59,7 +64,11 @@ class Img extends BaseElement
*/ */
public function getSrcAttribute() public function getSrcAttribute()
{ {
return new Attribute('src', $this->getUrl()->getAbsoluteUrl('&')); if (is_string($this->url)) {
return new Attribute('src', $this->url);
} else {
return new Attribute('src', $this->getUrl()->getAbsoluteUrl('&'));
}
} }
/** /**