public function revert(AssetInterface $asset, $versionId) { $version = $this->version->find($versionId); if ($version && $version->getAssetId() == $asset->getId()) { $attrs = $version->toArray(); unset($attrs['id']); $version = $this->version->create($attrs); copy($asset->directory() . DIRECTORY_SEPARATOR . $versionId, $asset->directory() . DIRECTORY_SEPARATOR . $version->getId()); } return $asset; }
public function thumb($width = null, $height = null) { if (!$this->asset->hasThumbnail()) { return $this->response->header('Content-type', 'image/png')->setContent(readfile(__DIR__ . "/../../../../../public/img/extensions/{$this->asset->getExtension()}.png")); } $thumbnail = $this->asset->getThumbnail(); $filename = $thumbnail->getFilename(); $im = new ImageManager(); if ($width || $height) { $image = $im->cache(function (ImageCache $cache) use($width, $height, $filename) { $width = empty($width) ? null : $width; $height = empty($height) ? null : $height; return $cache->make($filename)->resize($width, $height, function (Constraint $constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('image/png'); }); } else { $image = $im->make($filename)->encode(); } return $this->response->header('content-type', $thumbnail->getMimetype())->setContent($image); }
/** * Get the HTML code to embed an asset. * * @param Asset $asset * * @return string */ public static function assetEmbed(AssetInterface $asset, $height = null, $width = null) { return (string) $asset->getEmbedHtml($height, $width); }
public function thumb($width = null, $height = null) { return $this->response->header('Content-type', 'image/png')->setContent(readfile(__DIR__ . "/../../../../../public/img/extensions/{$this->asset->getExtension()}.png")); }
/** * @return string */ public function getFilename() { return $this->asset->getFilename() . '.thumb'; }