diff --git a/packages/web-twig/src/Resources/components/FileUploader/FileUploaderAttachment.twig b/packages/web-twig/src/Resources/components/FileUploader/FileUploaderAttachment.twig index c1aed104af..9003d356c4 100644 --- a/packages/web-twig/src/Resources/components/FileUploader/FileUploaderAttachment.twig +++ b/packages/web-twig/src/Resources/components/FileUploader/FileUploaderAttachment.twig @@ -35,7 +35,13 @@ > {% if _generateImagePreview or _imagePreview %} - {{- _fileName -}} + {{- _fileName -}} {% endif %} {% if not _imagePreview %} diff --git a/packages/web/src/js/FileUploader.ts b/packages/web/src/js/FileUploader.ts index 341ad24f1b..80b4c3f38c 100644 --- a/packages/web/src/js/FileUploader.ts +++ b/packages/web/src/js/FileUploader.ts @@ -265,7 +265,7 @@ class FileUploader extends BaseComponent { const itemButton = snippet.querySelector(`[${TEMPLATE_ELEMENT_SLOT_NAME}="button"]`); const hasImagePreview = Boolean((item as HTMLElement)?.dataset?.spiritImagepreview); const AttachmentSvgIcon = item?.querySelector('svg'); - const AttachmentPreviewImage = snippet.querySelector('.FileUploaderAttachment__image'); + const AttachmentPreviewImage = item?.querySelector('[data-spirit-element="attachment-image"]'); const isFileImg = file.type.includes('image'); if (hasImagePreview && isFileImg) { @@ -379,7 +379,9 @@ class FileUploader extends BaseComponent { this.fileQueue.set(name, newValue); - const itemImgElement = SelectorEngine.findOne(`#${name} .FileUploaderAttachment__image img`) as HTMLImageElement; + const itemImgElement = SelectorEngine.findOne( + `#${name} [data-spirit-element="attachment-image"] img`, + ) as HTMLImageElement; if (meta && itemImgElement && FileUploader.isCoordsInMeta(meta)) { const previewHeight = IMAGE_PREVIEW_HEIGHT; diff --git a/packages/web/src/scss/components/FileUploader/index.html b/packages/web/src/scss/components/FileUploader/index.html index d01c58f48b..66e9b1b5bf 100644 --- a/packages/web/src/scss/components/FileUploader/index.html +++ b/packages/web/src/scss/components/FileUploader/index.html @@ -826,7 +826,7 @@

FileUploader with Meta Data