This repository was archived by the owner on Mar 14, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 234
Display an Uploaded Image
Falieson edited this page Nov 26, 2015
·
3 revisions
Create a helper that returns your image files:
Template.imageView.helpers({
images: function () {
return Images.find(); // Where Images is an FS.Collection instance
}
});Use the url method with an img element in your markup:
<template name="imageView">
<div class="imageView">
{{#each images}}
<div>
<a href="{{this.url}}" target="_blank"><img src="{{this.url store='thumbs' uploading='/images/uploading.gif' storing='/images/storing.gif'}}" alt="" class="thumbnail" /></a>
</div>
{{/each}}
</div>
</template>Notes:
-
{{this.url}}will assume the first store in yourstoresarray. In this example, we're displaying the image from the "thumbs" store but wrapping it in a link that will load the image from the primary store (for example, the original image or a large image). - The
uploadingandstoringoptions allow you to specify a static image that will be shown in place of the real image while it is being uploaded and stored. You can alternatively useifblocks like{{#if this.isUploaded}}and{{#if this.hasStored 'thumbs'}}to display something different until upload and storage is complete. - These helpers are actually just instance methods on the
FS.Fileinstances, so there are others you can use, such asthis.isImage. See the API documentation. Theurlmethod is documented separately here.
footer25555555