This repository was archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathImageCell.js
More file actions
55 lines (49 loc) · 1.37 KB
/
ImageCell.js
File metadata and controls
55 lines (49 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { getRoot } from "mobx-state-tree";
import { FF_LSDV_4711, isFF } from "../../utils/feature-flags";
import { AnnotationPreview } from "../Common/AnnotationPreview/AnnotationPreview";
const imgDefaultProps = {};
if (isFF(FF_LSDV_4711)) imgDefaultProps.crossOrigin = 'anonymous';
export const ImageCell = (column) => {
const {
original,
value,
column: { alias },
} = column;
const root = getRoot(original);
const isDE = root.SDK.type === 'DE';
const renderImagePreview = original.total_annotations === 0 || !root.showPreviews;
const imgSrc = Array.isArray(value) ? value[0] : value;
if (!imgSrc) return null;
if (isDE) {
imgDefaultProps.crossOrigin = 'anonymous';
}
return renderImagePreview ? (
<img
{...imgDefaultProps}
key={imgSrc}
src={isDE ? `${imgSrc}${imgSrc.includes('?') ? '&' : '?'}isCacheable=true` : imgSrc}
alt="Data"
style={{
maxHeight: "100%",
maxWidth: "100px",
objectFit: "contain",
borderRadius: 3,
}}
/>
) : (
<AnnotationPreview
task={original}
annotation={original.annotations[0]}
config={getRoot(original).SDK}
name={alias}
variant="120x120"
fallbackImage={value}
style={{
maxHeight: "100%",
maxWidth: "100px",
objectFit: "contain",
borderRadius: 3,
}}
/>
);
};