Fixed: Dont create tag if image is 1px high
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
d2253a3417
commit
d94f21c852
|
@ -4,17 +4,14 @@ namespace Aweos\Resizer\Classes;
|
||||||
|
|
||||||
use Aweos\Resizer\Compressors\Compressor;
|
use Aweos\Resizer\Compressors\Compressor;
|
||||||
use Aweos\Resizer\Compressors\CompressorNotFoundException;
|
use Aweos\Resizer\Compressors\CompressorNotFoundException;
|
||||||
use Aweos\Resizer\Compressors\Factory as CompressorFactory;
|
|
||||||
use Aweos\Resizer\Exceptions\ResizerException;
|
use Aweos\Resizer\Exceptions\ResizerException;
|
||||||
use Aweos\Resizer\Lib\MediaPath;
|
use Aweos\Resizer\Lib\MediaPath;
|
||||||
use Aweos\Resizer\Models\Setting;
|
use Aweos\Resizer\Models\Setting;
|
||||||
use Cache;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Storage;
|
|
||||||
|
|
||||||
class TagGenerator {
|
|
||||||
|
|
||||||
|
class TagGenerator
|
||||||
|
{
|
||||||
private Compressor $compressor;
|
private Compressor $compressor;
|
||||||
public MediaPath $path;
|
public MediaPath $path;
|
||||||
private array $defaultOptions = [
|
private array $defaultOptions = [
|
||||||
|
@ -38,7 +35,7 @@ class TagGenerator {
|
||||||
|
|
||||||
$files = $this->possibleFiles($ratio);
|
$files = $this->possibleFiles($ratio);
|
||||||
|
|
||||||
if ($files === null) {
|
if (null === $files) {
|
||||||
return $this->fallback();
|
return $this->fallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,13 +77,16 @@ class TagGenerator {
|
||||||
$filename = $this->path->filename();
|
$filename = $this->path->filename();
|
||||||
$basePath = $this->path->versionsDirPath();
|
$basePath = $this->path->versionsDirPath();
|
||||||
[$originalWidth, $originalHeight] = $this->compressor->originalSize();
|
[$originalWidth, $originalHeight] = $this->compressor->originalSize();
|
||||||
$aspectRatio = $ratio === 'original'
|
$aspectRatio = 'original' === $ratio
|
||||||
? $originalWidth / $originalHeight
|
? $originalWidth / $originalHeight
|
||||||
: $this->size($ratio)[0] / $this->size($ratio)[1];
|
: $this->size($ratio)[0] / $this->size($ratio)[1];
|
||||||
|
|
||||||
$result = collect([]);
|
$result = collect([]);
|
||||||
|
|
||||||
foreach ($this->path->versions() as $version) {
|
foreach ($this->path->versions() as $version) {
|
||||||
|
if (1 === $version->get('height')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($version->get('width') / ($version->get('height') + 1) > $aspectRatio || $version->get('width') / ($version->get('height') - 1) < $aspectRatio) {
|
if ($version->get('width') / ($version->get('height') + 1) > $aspectRatio || $version->get('width') / ($version->get('height') - 1) < $aspectRatio) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -148,5 +148,4 @@ class TagGenerator {
|
||||||
|
|
||||||
return explode('x', $size['aspect_ratio']);
|
return explode('x', $size['aspect_ratio']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue