Guest User

Untitled

a guest
Dec 14th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public function image()
  2. {
  3. $img = Asset::find($this->getParam('id'));
  4. $retina = $this->getParam('retina');
  5.  
  6. if ($img->extension() == 'svg') {
  7. return File::get($img->resolvedPath());
  8. }
  9.  
  10. $width = $retina ? $img->width() / 2 : $img->width();
  11. $height = $retina ? $img->height() / 2 : $img->height();
  12.  
  13. return '<img src="' . $img->url() . '" width="'. $width .'" height="'. $height .'" alt="'. $img->get('alt') .'" />';
  14. }
Add Comment
Please, Sign In to add comment