【问题标题】:Meteor Collection FS thumbnails not showingMeteor Collection FS 缩略图未显示
【发布时间】: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


【解决方案1】:

试试这个:

添加发布(服务器代码):

Meteor.publish("images", function() {
    return Images.find({});
});

允许规则(服务器代码):

Images.allow({
    download: function(userId, doc) {
        return true;
    }
});

添加模板助手“图像”(客户端):

Template.your_template_name_here.helpers({
    images: function() {
        return Images.find()
    }
});

【讨论】:

  • 我还在等待解决方案。我在 Windows 8 上。我从这里安装了它。 sourceforge.net/projects/graphicsmagick/files 我想我错过了这个。是否需要安装其他东西?如何检查 gm 在我的机器上是否正常工作?
  • 通过运行 gm.isAvailable 检查 gm 是否可用...登录到控制台上 meteor.startup ,meteor.call 不管...你还应该安装包 cfs:filesystem
猜你喜欢
  • 1970-01-01
  • 2013-01-29
  • 2016-06-13
  • 2011-12-26
  • 2017-08-02
  • 1970-01-01
  • 1970-01-01
  • 2021-08-18
  • 1970-01-01
相关资源
最近更新 更多