aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Angular
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-02-04 14:10:21 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-02-04 14:10:42 +0200
commitc08af91d34665855100c969bad9fddbf2182af41 (patch)
tree6d62c473a87a52ee95c59fcdf27646116a54ed85 /src/DevHive.Angular
parent43b3762845fc16a2bfcb50c3654180d19b1fbfb4 (diff)
downloadDevHive-c08af91d34665855100c969bad9fddbf2182af41.tar
DevHive-c08af91d34665855100c969bad9fddbf2182af41.tar.gz
DevHive-c08af91d34665855100c969bad9fddbf2182af41.zip
Improved handling and detection of file types in post attachments
Diffstat (limited to 'src/DevHive.Angular')
-rw-r--r--src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html4
-rw-r--r--src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html
index a8ebce7..4d381d1 100644
--- a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html
+++ b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.html
@@ -10,8 +10,8 @@
</div>
<div class="show-full-attachment" *ngIf="showFull" (click)="toggleShowFull()">
- <img class="attachment-img" *ngIf="paramURL.includes('image')" src="{{paramURL}}">
- <a class="attachment-download submit-btn" *ngIf="!paramURL.includes('image')" href="{{paramURL}}">Download attachment</a>
+ <img class="attachment-img" *ngIf="isImage" src="{{paramURL}}">
+ <a class="attachment-download submit-btn" *ngIf="!isImage" href="{{paramURL}}">Download attachment</a>
<div class="close">
</div>
diff --git a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts
index 6c468b0..1d00def 100644
--- a/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts
+++ b/src/DevHive.Angular/src/app/components/post-attachment/post-attachment.component.ts
@@ -7,6 +7,7 @@ import { Component, Input, OnInit } from '@angular/core';
})
export class PostAttachmentComponent implements OnInit {
@Input() paramURL: string;
+ public isImage = false;
public showFull = false;
public fileName: string;
public fileType: string;
@@ -15,7 +16,8 @@ export class PostAttachmentComponent implements OnInit {
{ }
ngOnInit(): void {
- this.fileType = this.paramURL.includes('image') ? 'img' : 'raw';
+ this.isImage = this.paramURL.includes('image') && !this.paramURL.endsWith('pdf');
+ this.fileType = this.isImage ? 'img' : 'raw';
this.fileName = this.paramURL.match('(?<=\/)(?:.(?!\/))+$')?.pop() ?? 'Attachment';
}