I have a FS.collection that holds one image per posted item. I have a template that lists every single item, but every time a new item with a picture of it is uploaded, that newest uploaded picture replaces the picture for every single item.
Here is the CSS:
.demo-card-square > .mdl-card__title {
color: #fff;
background: url('{{image.url store="images"}}') bottom right 15% no-repeat #46B6AC;
}
Here is the declaration of the collection:
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});
Here is the item helper. It's supposed to get each item's unique photoID and then find the image in the collection. It seems like it only does it for the most recent image though:
Template.item.helpers({
image: function () {
console.log(this);
return Images.findOne(this.photo._id); // Where Images is an FS.Collection instance
}
});
I also checked the mongo shell, and the images are being successfully uploaded, so I know they're all successfully saved. Is there anything I need to change in the helper code to get the image to correctly display for each individual item? The other attributes of the item, such as its name and description, correctly show up on its respective template, but not the image.