【发布时间】:2015-06-22 19:50:50
【问题描述】:
我需要帮助
我正在尝试使用以下示例创建缩略图
https://github.com/CollectionFS/Meteor-CollectionFS#image-manipulation
我在 both/collections/common.js 中定义了以下代码
var createThumb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
};
Images =new FS.Collection('images',{
stores: [
new FS.Store.FileSystem("thumbs", {transformWrite: createThumb }),
new FS.Store.FileSystem('images',{path:'~/projectUploads'})
]
});
在模板上我有这个代码
{{#each images}}
<div>
<a href="{{url}}" target="_blank"><img src="{{url store='thumbs'}}" alt="image"/></a>
</div>
{{/each}}
这显示损坏的图像。同样在我的收藏拇指副本中说 size=0
如果我用 store="images" 原始图像显示更改上述代码
{{#each images}}
<div>
<a href="{{url}}" target="_blank"><img src="{{url store='images'}}" alt="image"/></a>
</div>
{{/each}}
我做错了什么?任何帮助真的很感激。从前几天我就被它困住了
【问题讨论】:
-
您的图像 {{#each images }} 模板助手是否返回图像 FS - 集合?
-
损坏的图像指向哪里?您是否添加了 cfs:graphicsmagick 包并安装了 GraphicsMagick 或 ImageMagick?
-
@bya 是的,它返回。我在助手中调用了 images.find() 。 Sander 是的,我已经安装了 cfs:GraphicMagick
-
我只想显示缩略图而不是真正的大图。图像正在显示,但我认为拇指没有创建..不知道为什么虽然从代码中看起来很简单。
标签: meteor