Skip to content

Commit

Permalink
Merge pull request #15477 from craftcms/bugfix/15402-image-transform-…
Browse files Browse the repository at this point in the history
…index

retain and use image transform index id
  • Loading branch information
brandonkelly authored Aug 5, 2024
2 parents eeb924c + e1eccc2 commit c32da66
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- Added `craft\filters\Cors`. ([#15397](https://github.com/craftcms/cms/pull/15397))
- Added `craft\filters\Headers`. ([#15397](https://github.com/craftcms/cms/pull/15397))
- Added `craft\helpers\App::configure()`.
- Added `craft\models\ImageTransform::$indexId`.
- Added `craft\web\View::clearAssetBundleBuffer()`.
- Added `craft\web\View::startAssetBundleBuffer()`.
- Added `Craft.EnvVarGenerator`.
Expand All @@ -52,3 +53,4 @@
- Updated Axios to 0.28.1. ([#15448](https://github.com/craftcms/cms/issues/15448))
- Fixed a bug where error messages returned by the `users/send-password-reset-email` action weren’t accounting for the `useEmailAsUsername` config setting. ([#15425](https://github.com/craftcms/cms/issues/15425))
- Fixed a bug where `$element->isNewForSite` was always `false` from fields’ `normalizeValue()` methods when propagating an element to a new site.
- Fixed a bug where `assets/generate-transforms` requests could generate the wrong transform, if another transform index with the same parameters existed. ([#15402](https://github.com/craftcms/cms/pull/15402), [#15477](https://github.com/craftcms/cms/pull/15477))
4 changes: 4 additions & 0 deletions src/imagetransforms/ImageTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ public function getTransformIndex(Asset $asset, mixed $transform): ImageTransfor
$query->andWhere(['format' => $transform->format]);
}

if ($transform->indexId !== null) {
$query->andWhere(['id' => $transform->indexId]);
}

$result = $query->one();

if ($result) {
Expand Down
6 changes: 6 additions & 0 deletions src/models/ImageTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class ImageTransform extends Model
*/
protected string $transformer = self::DEFAULT_TRANSFORMER;

/**
* @var int|null The image transform index ID (if one was passed to the request).
* @since 4.11.0
*/
public ?int $indexId = null;

/**
* @inheritdoc
*/
Expand Down
4 changes: 4 additions & 0 deletions src/models/ImageTransformIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ public function getTransform(): ImageTransform
$this->_transform->format = $this->format;
}

if ($this->id) {
$this->_transform->indexId = $this->id;
}

return $this->_transform;
}

Expand Down

0 comments on commit c32da66

Please sign in to comment.