Skip to content

Instantly share code, notes, and snippets.

@jhealey5
Created December 14, 2018 10:39
Show Gist options
  • Select an option

  • Save jhealey5/cbdbb79ef0153cb00c80ef5cc8475e8d to your computer and use it in GitHub Desktop.

Select an option

Save jhealey5/cbdbb79ef0153cb00c80ef5cc8475e8d to your computer and use it in GitHub Desktop.
Loads cms images/svgs inline
public function image()
{
$img = Asset::find($this->getParam('id'));
$retina = $this->getParam('retina');
if ($img->extension() == 'svg') {
return File::get($img->resolvedPath());
}
$width = $retina ? $img->width() / 2 : $img->width();
$height = $retina ? $img->height() / 2 : $img->height();
return '<img src="' . $img->url() . '" width="'. $width .'" height="'. $height .'" alt="'. $img->get('alt') .'" />';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment