This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/cdn-img.js.es6
2019-11-07 15:38:28 -06:00

20 lines
462 B
JavaScript

import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component";
import { htmlSafe } from "@ember/template";
export default Component.extend({
tagName: "",
@discourseComputed("src")
cdnSrc(src) {
return Discourse.getURLWithCDN(src);
},
@discourseComputed("width", "height")
style(width, height) {
if (width && height) {
return htmlSafe(`--aspect-ratio: ${width / height};`);
}
}
});