Bugfix: Block Type card thunbnail image path/URL (#2480)

Block Type Cards: Fixed image URL

Removed the backoffice path from the URL,
as the image paths are relative to the root of the website.
This commit is contained in:
Lee Kelleher
2024-11-04 13:07:13 +00:00
committed by Niels Lyngsø
parent 52f03b9c38
commit 59790431c4

View File

@@ -6,13 +6,14 @@ import { html, customElement, property, state, ifDefined } from '@umbraco-cms/ba
import { UmbRepositoryItemsManager } from '@umbraco-cms/backoffice/repository';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UMB_APP_CONTEXT } from '@umbraco-cms/backoffice/app';
import { removeLastSlashFromPath, transformServerPathToClientPath } from '@umbraco-cms/backoffice/utils';
import { transformServerPathToClientPath } from '@umbraco-cms/backoffice/utils';
import { UUICardEvent } from '@umbraco-cms/backoffice/external/uui';
@customElement('umb-block-type-card')
export class UmbBlockTypeCardElement extends UmbLitElement {
readonly #init: Promise<void>;
#appUrl: string = '';
//
#init: Promise<void>;
#serverUrl: string = '';
readonly #itemManager = new UmbRepositoryItemsManager<UmbDocumentTypeItemModel>(
this,
@@ -28,7 +29,8 @@ export class UmbBlockTypeCardElement extends UmbLitElement {
value = transformServerPathToClientPath(value);
if (value) {
this.#init.then(() => {
this._iconFile = removeLastSlashFromPath(this.#appUrl) + value;
const url = new URL(value, this.#serverUrl);
this._iconFile = url.href;
});
} else {
this._iconFile = undefined;
@@ -76,7 +78,7 @@ export class UmbBlockTypeCardElement extends UmbLitElement {
super();
this.#init = this.getContext(UMB_APP_CONTEXT).then((appContext) => {
this.#appUrl = appContext.getServerUrl() + appContext.getBackofficePath();
this.#serverUrl = appContext.getServerUrl();
});
this.observe(this.#itemManager.items, (items) => {