Skip to content

Commit 5e42e44

Browse files
committed
add image preview
1 parent 95180ba commit 5e42e44

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/packages/core/components/input-upload-field/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './input-upload-field-file.element.js';
33
export * from './input-upload-field-audio.element.js';
44
export * from './input-upload-field-video.element.js';
55
export * from './input-upload-field-svg.element.js';
6+
export * from './input-upload-field-image.element.js';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { html, customElement, property, css } from '@umbraco-cms/backoffice/external/lit';
2+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
3+
4+
@customElement('umb-input-upload-field-image')
5+
export class UmbInputUploadFieldImageElement extends UmbLitElement {
6+
@property({ type: String })
7+
path = '';
8+
9+
render() {
10+
if (!this.path) return html`<uui-loader></uui-loader>`;
11+
12+
return html`<img src=${this.path} alt="" />`;
13+
}
14+
15+
static styles = [
16+
css`
17+
:host {
18+
display: flex;
19+
height: 100%;
20+
position: relative;
21+
width: fit-content;
22+
max-height: 400px;
23+
}
24+
25+
img {
26+
max-width: 100%;
27+
max-height: 100%;
28+
object-fit: contain;
29+
width: auto;
30+
height: auto;
31+
}
32+
`,
33+
];
34+
}
35+
36+
declare global {
37+
interface HTMLElementTagNameMap {
38+
'umb-input-upload-field-image': UmbInputUploadFieldImageElement;
39+
}
40+
}

0 commit comments

Comments
 (0)