From 2a2406388e6dd198d96405d1532108ea0ccea455 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 13 Jul 2023 14:13:33 +0200 Subject: [PATCH] [Media(Libary)] Add webp + Fix no parameters on MediaLibrary select (#1808) (#1811) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | Doc PR? | no | Backport | 0.11 | License | MIT a) It was not possible to set output format of ImageFilter to webp although it already is possible in imagick and gd b) After selecting files in MediaLibrary, the parameters were not received and set in the newly generated FileParameters Form c) make it possible to edit alt/title of images in media library (cherry picked from commit fd35b4ae27a44e7445928348794f6b81cf45fa8b) Co-authored-by: visual.indi <7021685+indivisualvj@users.noreply.github.com> --- type/MediaItem.ts | 10 ++++++++++ type/MediaItemMeta.ts | 6 ++++-- type/MediaRow.ts | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/type/MediaItem.ts b/type/MediaItem.ts index e60d10360..bb860fecc 100644 --- a/type/MediaItem.ts +++ b/type/MediaItem.ts @@ -79,6 +79,15 @@ export default class MediaItem this.$element.find('[data-media-item-filename]').val(filename); } + setParameters(parameters:object): void { + for (let key in parameters) { + let param = this.$element.find('[data-parameter-key="' + key + '"]'); + if (param.length) { + param.val(parameters[key]); + } + } + } + setId(id:number) { this.meta.id = id; @@ -125,6 +134,7 @@ export default class MediaItem case 'image/jpg': case 'image/jpeg': case 'image/gif': + case 'image/webp': mediaThumb.css('background-image', 'url('+this.getThumbUrl()+')'); break; case 'video/mpeg': diff --git a/type/MediaItemMeta.ts b/type/MediaItemMeta.ts index 459a6fa09..04fcdd3f2 100644 --- a/type/MediaItemMeta.ts +++ b/type/MediaItemMeta.ts @@ -13,5 +13,7 @@ export default class MediaItemMeta token: string; - order: number -} \ No newline at end of file + order: number; + + parameters: object +} diff --git a/type/MediaRow.ts b/type/MediaRow.ts index 821ab1aab..f3bfe72e5 100644 --- a/type/MediaRow.ts +++ b/type/MediaRow.ts @@ -85,6 +85,7 @@ export default class MediaRow let item = new MediaItem(html, meta, this); item.setFilename(meta.filename); item.setId(meta.id); + item.setParameters(meta.parameters); this.items.push(item); this.$element.append(html); $(document).trigger('mediaAddItem', [item]); @@ -211,4 +212,4 @@ export default class MediaRow }); } } -} \ No newline at end of file +}