Files
SCM-Manager/scm-ui/ui-components/src/Image.tsx

26 lines
504 B
TypeScript
Raw Normal View History

import React from "react";
import { withContextPath } from "./urls";
type Props = {
src: string;
alt: string;
className?: any;
};
class Image extends React.Component<Props> {
2018-10-18 14:40:35 +02:00
createImageSrc = () => {
const { src } = this.props;
if (src.startsWith("http")) {
2018-10-18 14:40:35 +02:00
return src;
}
return withContextPath(src);
};
render() {
2018-10-18 14:40:35 +02:00
const { alt, className } = this.props;
return <img className={className} src={this.createImageSrc()} alt={alt} />;
}
}
export default Image;