MDL-82718 tiny_media: fix error string loading for invalid image.

This commit is contained in:
Paul Holden 2024-08-06 09:02:41 +01:00
parent 056f473a6e
commit f803f62853
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
3 changed files with 10 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,6 +27,7 @@ import {getImagePermissions} from './options';
import {getFilePicker} from 'editor_tiny/options';
import {ImageInsert} from 'tiny_media/imageinsert';
import {ImageDetails} from 'tiny_media/imagedetails';
import {prefetchStrings} from 'core/prefetch';
import {getString} from 'core/str';
import {
bodyImageInsert,
@ -38,6 +39,11 @@ import {
isPercentageValue,
} from 'tiny_media/imagehelpers';
prefetchStrings('tiny_media', [
'imageurlrequired',
'sizecustom_help',
]);
export default class MediaImage {
canShowFilePicker = false;
editor = null;
@ -138,9 +144,9 @@ export default class MediaImage {
this.startImageLoading();
const image = new Image();
image.src = url;
image.addEventListener('error', () => {
image.addEventListener('error', async() => {
const urlWarningLabelEle = this.root.querySelector(Selectors.IMAGE.elements.urlWarning);
urlWarningLabelEle.innerHTML = this.langStrings.imageurlrequired;
urlWarningLabelEle.innerHTML = await getString('imageurlrequired', 'tiny_media');
showElements(Selectors.IMAGE.elements.urlWarning, this.root);
this.stopImageLoading();
});