Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

how to display images of a array? #57

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

how to display images of a array? #57

veritme opened this issue Jul 9, 2016 · 0 comments

Comments

@veritme
Copy link

veritme commented Jul 9, 2016

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="Posts">
  {{> NewPost}}
  <div class="col-lg-6 col-lg-offset-3">
    {{#each posts}}
      {{> Post}}
    {{/each}}
  </div>
</template>
<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>


Meteor.publish("postAndImage",function(){
  return[
    Posts.find({author:this.userId}),
    Images.find({})
  ]
})
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant