forked from Public/pics
EditAsset: refactor common expression into its own variable.
This commit is contained in:
parent
b8191bf554
commit
c72e24c0c7
@ -116,20 +116,22 @@ class EditAsset extends HTMLController
|
|||||||
if (!preg_match('~^(?<width>\d+)x(?<height>\d+)(?<suffix>_c(?<method>[best]?))?$~', $selector, $thumb))
|
if (!preg_match('~^(?<width>\d+)x(?<height>\d+)(?<suffix>_c(?<method>[best]?))?$~', $selector, $thumb))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
$dimensions = $thumb['width'] . 'x' . $thumb['height'];
|
||||||
|
|
||||||
// Does the thumbnail exist on disk? If not, use an url to generate it.
|
// Does the thumbnail exist on disk? If not, use an url to generate it.
|
||||||
if (!$filename || !file_exists(THUMBSDIR . '/' . $subdir . '/' . $filename))
|
if (!$filename || !file_exists(THUMBSDIR . '/' . $subdir . '/' . $filename))
|
||||||
$thumb_url = BASEURL . '/thumbnail/' . $image->getId() . '/' . $thumb['width'] . 'x' . $thumb['height'] . ($thumb['suffix'] ?? '') . '/';
|
$thumb_url = BASEURL . '/thumbnail/' . $image->getId() . '/' . $dimensions . ($thumb['suffix'] ?? '') . '/';
|
||||||
else
|
else
|
||||||
$thumb_url = THUMBSURL . '/' . $subdir . '/' . $filename;
|
$thumb_url = THUMBSURL . '/' . $subdir . '/' . $filename;
|
||||||
|
|
||||||
$has_crop_boundary = isset($metadata['crop_' . $thumb['width'] . 'x' . $thumb['height']]);
|
$has_crop_boundary = isset($metadata['crop_' . $dimensions]);
|
||||||
$has_custom_image = isset($metadata['custom_' . $thumb['width'] . 'x' . $thumb['height']]);
|
$has_custom_image = isset($metadata['custom_' . $dimensions]);
|
||||||
|
|
||||||
$thumbs[] = [
|
$thumbs[] = [
|
||||||
'dimensions' => [(int) $thumb['width'], (int) $thumb['height']],
|
'dimensions' => [(int) $thumb['width'], (int) $thumb['height']],
|
||||||
'cropped' => !$has_custom_image && (!empty($thumb['suffix']) || $has_crop_boundary),
|
'cropped' => !$has_custom_image && (!empty($thumb['suffix']) || $has_crop_boundary),
|
||||||
'crop_method' => !$has_custom_image && !empty($thumb['method']) ? $thumb['method'] : (!empty($thumb['suffix']) ? 'c' : null),
|
'crop_method' => !$has_custom_image && !empty($thumb['method']) ? $thumb['method'] : (!empty($thumb['suffix']) ? 'c' : null),
|
||||||
'crop_region' => $has_crop_boundary ? $metadata['crop_' . $thumb['width'] . 'x' . $thumb['height']] : null,
|
'crop_region' => $has_crop_boundary ? $metadata['crop_' . $dimensions] : null,
|
||||||
'custom_image' => $has_custom_image,
|
'custom_image' => $has_custom_image,
|
||||||
'filename' => $filename,
|
'filename' => $filename,
|
||||||
'url' => $thumb_url,
|
'url' => $thumb_url,
|
||||||
|
Loading…
Reference in New Issue
Block a user