Skip to content

Commit

Permalink
Closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
DynamicsNinja committed Sep 8, 2020
1 parent fa93bab commit 98c406d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion GalleryFieldControl/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest>
<control namespace="Fic" constructor="GalleryFieldControl" version="1.3.2" display-name-key="Fic.GalleryFieldControl" description-key="Fic.GalleryFieldControl" control-type="standard">
<control namespace="Fic" constructor="GalleryFieldControl" version="1.3.3" display-name-key="Fic.GalleryFieldControl" description-key="Fic.GalleryFieldControl" control-type="standard">
<property name="sampleProperty" display-name-key="Property_Display_Key" description-key="Property_Desc_Key" of-type="SingleLine.Text" usage="bound" required="true" />
<property name="thumbnailHeight" display-name-key="Thumbnail Height(px)" description-key="Thumbnail Height(px)" of-type="Whole.None" usage="input" required="false" />
<property name="thumbnailWidth" display-name-key="Thumbnail Width(px)" description-key="Thumbnail Width(px)" of-type="Whole.None" usage="input" required="false" />
Expand Down
12 changes: 9 additions & 3 deletions GalleryFieldControl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export class GalleryFieldControl implements ComponentFramework.StandardControl<I
private _thumbnailClicked: EventListenerOrEventListenerObject;
private _clearPreviewImage: EventListenerOrEventListenerObject;

private supportedMimeTypes: string[] = ["image/jpeg", "image/png", "image/svg+xml"];
private _supportedMimeTypes: string[] = ["image/jpeg", "image/png", "image/svg+xml"];
private _supportedExtensions : string[] = [".jpg", ".jpeg", ".png", ".svg", ".gif"];

constructor() {

Expand Down Expand Up @@ -167,7 +168,9 @@ export class GalleryFieldControl implements ComponentFramework.StandardControl<I
let content = <string>record["body"] || <string>record["documentbody"];
let fileSize = <number>record["filesize"];

if (!this.supportedMimeTypes.includes(mimeType)) { continue; }
const ext = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();

if (!this._supportedMimeTypes.includes(mimeType) && !this._supportedExtensions.includes(ext)) { continue; }

let file = new AttachedFile(fileName, mimeType, content, fileSize);
items.push(file);
Expand Down Expand Up @@ -203,11 +206,14 @@ export class GalleryFieldControl implements ComponentFramework.StandardControl<I
let record = result.entities[i];

let mimeType = <string>record["mimetype"];
if (!this.supportedMimeTypes.includes(mimeType)) { continue; }
let fileName = <string>record["filename"];
let content = <string>record["body"] || <string>record["documentbody"];
let fileSize = <number>record["filesize"];

const ext = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();

if (!this._supportedMimeTypes.includes(mimeType) && !this._supportedExtensions.includes(ext)) { continue; }

let file = new AttachedFile(fileName, mimeType, content, fileSize);
items.push(file);
}
Expand Down

0 comments on commit 98c406d

Please sign in to comment.