-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2107 from umbraco/v14/fix/badge-thumbnails
Bugfix: Resized media urls result in the request path being too long
- Loading branch information
Showing
7 changed files
with
113 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const UMB_IMAGING_REPOSITORY_ALIAS = 'Umb.Repository.Imaging'; | ||
export const UMB_IMAGING_STORE_ALIAS = 'Umb.Store.Imaging'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type { UmbImagingStore } from './imaging.store.js'; | ||
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; | ||
|
||
export const UMB_IMAGING_STORE_CONTEXT = new UmbContextToken<UmbImagingStore>('UmbImagingStore'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { UMB_IMAGING_STORE_CONTEXT } from './imaging.store.token.js'; | ||
import type { UmbImagingModel } from './types.js'; | ||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; | ||
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api'; | ||
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; | ||
|
||
export class UmbImagingStore extends UmbContextBase<never> implements UmbApi { | ||
#data; | ||
|
||
constructor(host: UmbControllerHost) { | ||
super(host, UMB_IMAGING_STORE_CONTEXT.toString()); | ||
this.#data = new Map<string, Map<string, string>>(); | ||
} | ||
|
||
/** | ||
* Gets the data from the store. | ||
*/ | ||
getData(unique: string) { | ||
return this.#data.get(unique); | ||
} | ||
|
||
/** | ||
* Gets a specific crop if it exists. | ||
*/ | ||
getCrop(unique: string, data?: UmbImagingModel) { | ||
return this.#data.get(unique)?.get(this.#generateCropKey(data)); | ||
} | ||
|
||
/** | ||
* Adds a new crop to the store. | ||
*/ | ||
addCrop(unique: string, urlInfo: string, data?: UmbImagingModel) { | ||
if (!this.#data.has(unique)) { | ||
this.#data.set(unique, new Map()); | ||
} | ||
this.#data.get(unique)?.set(this.#generateCropKey(data), urlInfo); | ||
} | ||
|
||
/** | ||
* Generates a unique key for the crop based on the width, height and mode. | ||
*/ | ||
#generateCropKey(data?: UmbImagingModel) { | ||
return data ? `${data.width}x${data.height};${data.mode}` : 'generic'; | ||
} | ||
} | ||
|
||
export default UmbImagingStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters