add image preview

This commit is contained in:
JesmoDev
2024-04-25 10:23:55 +02:00
parent d92bdf2cfb
commit 342af27497
2 changed files with 41 additions and 0 deletions

View File

@@ -3,3 +3,4 @@ export * from './input-upload-field-file.element.js';
export * from './input-upload-field-audio.element.js';
export * from './input-upload-field-video.element.js';
export * from './input-upload-field-svg.element.js';
export * from './input-upload-field-image.element.js';

View File

@@ -0,0 +1,40 @@
import { html, customElement, property, css } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
@customElement('umb-input-upload-field-image')
export class UmbInputUploadFieldImageElement extends UmbLitElement {
@property({ type: String })
path = '';
render() {
if (!this.path) return html`<uui-loader></uui-loader>`;
return html`<img src=${this.path} alt="" />`;
}
static styles = [
css`
:host {
display: flex;
height: 100%;
position: relative;
width: fit-content;
max-height: 400px;
}
img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
width: auto;
height: auto;
}
`,
];
}
declare global {
interface HTMLElementTagNameMap {
'umb-input-upload-field-image': UmbInputUploadFieldImageElement;
}
}