【发布时间】:2017-05-30 04:51:06
【问题描述】:
我正在使用 Meteor 和 Cloudinary 来显示上传和显示个人资料图片。
问题 删除个人资料图像后(通过图像 id),字段 profilepicId 仍然存在,但显示未定义。因此,助手似乎无法确定 profilepicId 是否存在,并不断显示 Gravatar(尽管有上传的图像),或者在删除图像时不显示任何 gravatar。
使用蒙古语,字段显示"profilepicId": {}
个人资料 html
{{#with currentUser}}
{{#if profilepicId}}
<img src="{{c.url profilepicId format=format gravity='faces' mode='thumb' crop='thumb' width=60 height=60}}">
{{else}}
<div class="avatar" style="background: url({{avatar 40}}); height: 50px; width: 50px; float:left;"></div>
{{/if}}
{{/with}}
个人资料 js
Template.profile.onCreated(function(){
var self = this;
self.autorun(function(){
self.subscribe('user', Meteor.userId());
$.cloudinary.config({ cloud_name: "XX", api_key: 'XX' });
});
});
Template.profile.helpers({
user: function () {
return Meteor.user();
},
profilepicId: function (){
var u = Meteor.user().profile;
if( u.profilepicId === undefined || u.profilepicId === null){
return false
}
}
});
【问题讨论】:
-
删除图片后为什么不
unset那个字段? -
@Khang 你是什么意思,我应该如何解除它?
标签: javascript html meteor cloudinary