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