Fixed scaled image medium filename when using non-existing retina file

This commit is contained in:
Matias Griese 2022-01-10 22:12:09 +02:00
parent bd471cb61b
commit 55b45fcf2f
3 changed files with 6 additions and 1 deletions

View File

@ -11,6 +11,7 @@
* Reorganized the Asset system configuration blueprint for clarity
3. [](#bugfix)
* Fixed CLI `--env` and `--lang` options having no effect if they aren't added before all the other options
* Fixed scaled image medium filename when using non-existing retina file
# v1.7.26.1
## 01/04/2022

View File

@ -23,6 +23,8 @@ use Grav\Common\Media\Traits\MediaObjectTrait;
* @package Grav\Common\Page\Medium
*
* @property string $filepath
* @property string $filename
* @property string $basename
* @property string $mime
* @property int $size
* @property int $modified

View File

@ -193,7 +193,7 @@ class MediumFactory
$height = $medium->get('height') * $ratio;
$prev_basename = $medium->get('basename');
$basename = str_replace('@'.$from.'x', '@'.$to.'x', $prev_basename);
$basename = str_replace('@' . $from . 'x', $to !== 1 ? '@' . $to . 'x' : '', $prev_basename);
$debug = $medium->get('debug');
$medium->set('debug', false);
@ -208,6 +208,8 @@ class MediumFactory
$medium = self::fromFile($file);
if ($medium) {
$medium->set('basename', $basename);
$medium->set('filename', $basename . '.' . $medium->extension);
$medium->set('size', $size);
}