Skip to content

Commit 7cb8505

Browse files
kilchenmannmdelez
andauthored
fix(upload): fix thumbnail preview (DEV-268) (#619)
Co-authored-by: mdelez <60604010+mdelez@users.noreply.github.com>
1 parent daa4167 commit 7cb8505

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

‎src/app/workspace/resource/representation/upload/upload.component.html‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222

2323
<ng-container *ngIf="!isLoading && file">
2424
<div *ngIf="thumbnailUrl" class="thumbnail">
25-
<img src="{{ thumbnailUrl }}" alt="thumbnail" />
26-
<button mat-button class="delete-file" title="delete file" (click)="deleteAttachment()">
27-
<mat-icon>close</mat-icon>
28-
</button>
25+
<img [src]="thumbnailUrl" alt="thumbnail" />
2926
</div>
3027

3128
<div class="files-list">

‎src/app/workspace/resource/representation/upload/upload.component.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
22
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
3+
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
34
import {
45
CreateArchiveFileValue,
56
CreateAudioFileValue,
@@ -38,7 +39,7 @@ export class UploadComponent implements OnInit {
3839
form: FormGroup;
3940
fileControl: FormControl;
4041
isLoading = false;
41-
thumbnailUrl: string;
42+
thumbnailUrl: string | SafeUrl;
4243

4344
allowedFileTypes: string[];
4445
// todo: maybe we can use this list to display which file format is allowed to
@@ -47,13 +48,10 @@ export class UploadComponent implements OnInit {
4748
supportedAudioTypes = ['audio/mpeg'];
4849
supportedArchiveTypes = ['application/zip', 'application/x-tar', 'application/gzip'];
4950

50-
// readonly fromLabels = {
51-
// upload: 'Upload file',
52-
// drag_drop: 'Drag and drop or click to upload'
53-
// };
5451
constructor(
5552
private _fb: FormBuilder,
5653
private _notification: NotificationService,
54+
private _sanitizer: DomSanitizer,
5755
private _upload: UploadFileService
5856
) { }
5957

@@ -97,7 +95,7 @@ export class UploadComponent implements OnInit {
9795
case 'stillImage':
9896
const temporaryUrl = res.uploadedFiles[0].temporaryUrl;
9997
const thumbnailUri = '/full/256,/0/default.jpg';
100-
this.thumbnailUrl = `${temporaryUrl}${thumbnailUri}`;
98+
this.thumbnailUrl = this._sanitizer.bypassSecurityTrustUrl(temporaryUrl + thumbnailUri);
10199
break;
102100

103101
case 'document':

0 commit comments

Comments
 (0)