From 6ecf2c68d0e6426c8ed5a82d8135e1e630ecb9d0 Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Fri, 19 May 2023 01:17:32 -0400 Subject: [PATCH 1/2] Use filename data --- src/elements/Asset.php | 1 + src/elements/actions/RenameFile.php | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/elements/Asset.php b/src/elements/Asset.php index d3b8def9035..6665de823d9 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -2928,6 +2928,7 @@ protected function htmlAttributes(string $context): array 'data' => [ 'kind' => $this->kind, 'alt' => $this->alt, + 'filename' => $this->filename, ], ]; diff --git a/src/elements/actions/RenameFile.php b/src/elements/actions/RenameFile.php index dd99064781d..8483862a13e 100644 --- a/src/elements/actions/RenameFile.php +++ b/src/elements/actions/RenameFile.php @@ -41,11 +41,7 @@ public function getTriggerHtml(): ?string activate: \$selectedItems => { const \$element = \$selectedItems.find('.element') const assetId = \$element.data('id'); - let oldName = \$element.data('url').split('/').pop(); - - if (oldName.indexOf('?') !== -1) { - oldName = oldName.split('?').shift(); - } + let oldName = \$element.data('filename'); const newName = prompt($prompt, oldName); From cb712c4c4315369d74727097b595f4fc4eaa3166 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 26 May 2023 14:57:46 -0700 Subject: [PATCH 2/2] Release note [ci skip] --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50e2158623a..be86ecbdac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft CMS 4 +## Unreleased + +- Fixed a JavaScript error that could occur when renaming assets without URLs. ([#13223](https://github.com/craftcms/cms/pull/13223)) + ## 4.4.13 - 2023-05-24 - Fixed a bug where asset sources weren‘t immediately showing a source path on a clear `localStorage` cache.