Skip to content

Commit

Permalink
Merge branch '2.0' into 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Oct 29, 2018
2 parents e4549e7 + 99e4e8a commit 8494ed6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/FileStorage/Filesystems/LocalFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,18 @@ public function meta(ResourceInterface $resource): FileMetaInterface
public function response(ResourceInterface $resource, ?string $rule = null): Response
{
if ($this->meta($resource)->hasImage()) {
$pathinfo = \League\Flysystem\Util::pathinfo($resource->getPath());
$rule = new Local\RuleParser($rule);
if (
$rule->getQuality() >= 90 &&
! $rule->getBlur() &&
! $rule->getWidth() &&
! $rule->getHeight() &&
strtolower($this->meta($resource)->getMimeType()) === 'image/gif'
) {
return $this->filesystem->response($resource->getPath());
}

$pathinfo = \League\Flysystem\Util::pathinfo($resource->getPath());
$cachePath = sprintf('%s/%s/%s.%s', $pathinfo['dirname'], $pathinfo['filename'], $rule->getFilename(), $pathinfo['extension']);
if ($this->filesystem->has($cachePath)) {
return $this->filesystem->response($cachePath);
Expand Down

0 comments on commit 8494ed6

Please sign in to comment.