Add default width parameter to resizer

This commit is contained in:
Lewis Dale 2023-08-25 21:24:51 +01:00
parent 03b13733ff
commit 1aa76cb053
2 changed files with 5 additions and 4 deletions

View File

@ -0,0 +1,3 @@
ROOT_DOMAIN=https://lewisdale.dev
DB_NAME=image_resizer.db
DEFAULT_WIDTH=600

View File

@ -26,7 +26,7 @@ class Resizer
}
// Fetch the image at the given URL
$original_img = Image::fromUrl($_ENV['root_domain'] . $path);
$original_img = Image::fromUrl($_ENV['ROOT_DOMAIN'] . $path);
$converted = $this->createVariant($original_img, $params);
// Store the image in the database
@ -44,9 +44,7 @@ class Resizer
{
$quality = $params->quality ?: -1;
if ($params->width) {
$original->toWidth($params->width);
}
$original->toWidth($params->width ?? intval($_ENV["DEFAULT_WIDTH"]));
return $original->encode($quality);
}