diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d0a337a3b..a39e16273ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed an error that could occur when setting `relatedTo*` GraphQL arguments to `null`. ([#16433](https://github.com/craftcms/cms/issues/16433)) - Fixed a bug where old structure data wasn’t getting soft-deleted when a section was assigned a new structure UUID when applying project config changes. ([#16450](https://github.com/craftcms/cms/issues/16450)) +- Fixed a bug where `craft\events\DefineAssetUrlEvent::$transform` wasn’t always defined for assets’ `EVENT_BEFORE_DEFINE_URL` and `EVENT_DEFINE_URL` events. ([#16464](https://github.com/craftcms/cms/pull/16464)) ## 4.13.10 - 2025-01-14 diff --git a/src/elements/Asset.php b/src/elements/Asset.php index 67ff633a505..4a078a1c021 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -1924,6 +1924,8 @@ public function getUrl(mixed $transform = null, ?bool $immediately = null): ?str return null; } + $transform = $transform ?? $this->_transform; + // Give plugins/modules a chance to provide a custom URL $event = new DefineAssetUrlEvent([ 'transform' => $transform, @@ -1961,7 +1963,6 @@ private function _url(mixed $transform = null, ?bool $immediately = null): ?stri } $volume = $this->getVolume(); - $transform = $transform ?? $this->_transform; if ( $transform && (