2019-10-20 16:59:02 +02:00
|
|
|
import React from "react";
|
|
|
|
|
import { withContextPath } from "./urls";
|
2018-09-03 16:17:36 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
src: string;
|
|
|
|
|
alt: string;
|
2019-10-29 16:44:35 +01:00
|
|
|
className?: string;
|
2018-09-03 16:17:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Image extends React.Component<Props> {
|
2018-10-18 14:40:35 +02:00
|
|
|
createImageSrc = () => {
|
|
|
|
|
const { src } = this.props;
|
2019-10-20 16:59:02 +02:00
|
|
|
if (src.startsWith("http")) {
|
2018-10-18 14:40:35 +02:00
|
|
|
return src;
|
|
|
|
|
}
|
|
|
|
|
return withContextPath(src);
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-03 16:17:36 +02:00
|
|
|
render() {
|
2018-10-18 14:40:35 +02:00
|
|
|
const { alt, className } = this.props;
|
|
|
|
|
return <img className={className} src={this.createImageSrc()} alt={alt} />;
|
2018-09-03 16:17:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Image;
|