Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How display images array #111

Open
veritme opened this issue Jul 8, 2016 · 0 comments
Open

How display images array #111

veritme opened this issue Jul 8, 2016 · 0 comments

Comments

@veritme
Copy link

veritme commented Jul 8, 2016

This is my code

Images = new FS.Collection("images",{
  stores: [new FS.Store.FileSystem("images")],
  filter:{
    allow:{
      contentTypes: ['image/*']
    }
  }
});
Images.allow({
  insert: function(userId,doc){
    return true;
  },
  update:function(userId,doc){
    return true;
  },
  download: function(userId){
    return true;
  }
});
Posts = new Meteor.Collection('posts');

Posts.allow({
  insert:function(userId,doc){
    return true;
  },
  update:function(userId,doc){
    return true;
  }
});
PostSchema = new SimpleSchema({
  title:{
    type: String,
    autoform:{
      label:false,
      type:"textarea",
      placeholder:"Comparte con la comunidad"
    }
  },
  pictures:{
    type:[String],
    optional: true,
    label: " "
  },
  'pictures.$':{
    autoform:{
      type:"fileUpload",
      collection: 'images',
      selectFileBtnTemplate: 'mySelectFileBtn',
      previewTemplate: 'myFilePreview',
      uploadProgressTemplate: 'myUploadProgressTemplate'
    }
  },
  author:{
    type:String,
    label: "Author",
    autoValue: function(){
      return this.userId
    },
    autoform:{
      type:"hidden"
    }
  },
  createdAt:{
    type: Date,
    label: "created At",
    autoValue:function(){
      return new Date()
    },
    autoform:{
      type:"hidden"
    }
  }
});
Posts.attachSchema(PostSchema);

`

<template name="Post">
  <div class="card">
    <div class="card-header">
      Bryan zamora
    </div>
    <div class="card-block">
      <p class="card-text">{{title}}</p>
      {{#each FS.GetFile "images" pictures}}
        <img src="{{this.name}}" alt="" class="card-img-bottom">
      {{/each}}
    </div>
  </div>
</template>
<template name="Posts">
  {{> NewPost}}
  <div class="col-lg-6 col-lg-offset-3">
    {{#each posts}}
      {{> Post}}
    {{/each}}
  </div>
</template>
Meteor.publish("postAndImage",function(){
  return[
    Posts.find({author:this.userId}),
    Images.find({})
  ]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant