我剛剛遇到了一個問題,看來我的圖像有時只是稍微加載。有時當我手動刷新頁面時,它們會完全加載,但很多時候會發生這種情況 - http://i.gyazo.com/a7050e430c79aa31ba557fc8271f1502.pngCollectionFS圖像未完全加載
不確定爲什麼會發生這種情況,我正在使用cfs-ejson-file和cfs-s3的collectionFS來存儲圖片。
這裏是一些示例代碼(主個人資料圖片)
模板代碼 -
<div class="profile-avatar" style="height: 261px; margin-bottom: 30px;">
{{#if avatar }}
{{#if avatarReady }}
<img width="261px" height="261px" src="{{avatar.url}}" class="profile-avatar-img thumbnail" alt="Profile Image">
{{else}}
<div class="activity-spinner">
{{>spinner}}
</div>
{{/if}}
{{else}}
<img data-src="holder.js/100%x100%/text:No Profile Photo">
{{/if}}
</div> <!-- /.profile-avatar -->
JS代碼 -
Template.profileLeft.helpers({
avatar: function(){
if(this.profile && this.profile.images)
return Images.findOne(this.profile.images[0]._id);
},
avatarReady: function(){
if(this.profile && this.profile.images){
var image = Images.findOne(this.profile.images[0]._id);
return image && image.isUploaded && image.hasStored("images");
}
},
});