浏览代码

fixup! fix: cover image - works now

David Arnold 4 年之前
父节点
当前提交
2c175f2be6
共有 2 个文件被更改,包括 5 次插入2 次删除
  1. 1 1
      client/components/cards/minicard.jade
  2. 4 1
      models/cards.js

+ 1 - 1
client/components/cards/minicard.jade

@@ -7,7 +7,7 @@ template(name="minicard")
       .handle
         .fa.fa-arrows
     if cover
-      .minicard-cover(style="background-image: url('{{cover.link}}');")
+      .minicard-cover(style="background-image: url('{{cover.link 'original' '/'}}');")
     if labels
       .minicard-labels(class="{{#if hiddenMinicardLabelText}}minicard-labels-no-text{{/if}}")
         each labels

+ 4 - 1
models/cards.js

@@ -750,7 +750,10 @@ Cards.helpers({
 
   cover() {
     if (!this.coverId) return false;
-    return Attachments.findOne(this.coverId);
+    const cover = Attachments.findOne(this.coverId);
+    // if we return a cover before it is fully stored, we will get errors when we try to display it
+    // todo XXX we could return a default "upload pending" image in the meantime?
+    return cover && cover.path && cover;
   },
 
   checklists() {