Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/cuba-app/cuba-app-aware-behavior.html">
<!--
Polymer element for displaying image from CUBA app file storage.
<myapp-fd-img file-descriptor="[[car.photo]]"></myapp-fd-img>
-->
<dom-module id="myapp-fd-img">
<template>
<style>
:host {
display: inline-block;
}
</style>
<img src="[[_computeSrc(app, fileDescriptor)]]">
</template>
<script>
Polymer({
is: 'myapp-fd-img',
behaviors: [CubaAppAwareBehavior],
properties: {
fileDescriptor: {
type: Object
}
},
_computeSrc: function(app, fileDescriptor) {
if (app && fileDescriptor) {
var url = app.apiUrl + 'v2/files/' + fileDescriptor.id;
if (app.restApiToken) {
url += '?access_token=' + app.restApiToken;
}
return url;
}
}
});
</script>
</dom-module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment