This repository has been archived by the owner on Mar 14, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 237
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 yourstores
array. 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
uploading
andstoring
options 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 useif
blocks 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.File
instances, so there are others you can use, such asthis.isImage
. See the API documentation. Theurl
method is documented separately here.
footer25555555