Browse Source

Add support for bmp

Steven Silvester 9 years ago
parent
commit
fa465daff3
1 changed files with 2 additions and 3 deletions
  1. 2 3
      src/imagehandler/plugin.ts

+ 2 - 3
src/imagehandler/plugin.ts

@@ -49,7 +49,7 @@ class ImageHandler extends AbstractFileHandler {
    * Get the list of file extensions explicitly supported by the handler.
    * Get the list of file extensions explicitly supported by the handler.
    */
    */
   get fileExtensions(): string[] {
   get fileExtensions(): string[] {
-    return ['.png', '.gif', '.jpeg', '.jpg', '.svg']
+    return ['.png', '.gif', '.jpeg', '.jpg', '.svg', '.bmp']
   }
   }
 
 
   /**
   /**
@@ -78,8 +78,7 @@ class ImageHandler extends AbstractFileHandler {
    */
    */
   protected populateWidget(widget: Widget, model: IContentsModel): Promise<void> {
   protected populateWidget(widget: Widget, model: IContentsModel): Promise<void> {
     let ext = model.path.split('.').pop();
     let ext = model.path.split('.').pop();
-    let uri = `data:image/${ext};base64,${model.content}`;
-    if (ext === 'svg') uri = `data:image/svg+xml;utf-8,${model.content}`;
+    let uri = `data:${model.mimetype};${model.format},${model.content}`;
     var img = new Image();
     var img = new Image();
     var canvas = widget.node.firstChild as HTMLCanvasElement;
     var canvas = widget.node.firstChild as HTMLCanvasElement;
     img.addEventListener('load', () => {
     img.addEventListener('load', () => {