Loading editor/html/js/properties.js +23 −0 Changes for editor/html/js/properties.js: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -512,6 +512,22 @@ var PropertiesPanel = (function() { if (value === field.options[j]) opt.selected = true; input.appendChild(opt); } // The "Format" dropdown (media_id-backed image/video widgets) and // the "src" text field are separate, independently-saved // properties. Without this, changing the format here leaves the // stored src pointing at the old extension, so the preview (and // the published page) keep serving the previous format. if (field.key === 'media_ext') { (function(sel) { sel.addEventListener('change', function() { var mediaIdInput = form.querySelector('input[name="media_id"]'); var srcInput = form.querySelector('input[name="src"]'); if (mediaIdInput && mediaIdInput.value && srcInput && sel.value) { srcInput.value = srcInput.value.replace(/\.[a-zA-Z0-9]+$/, '.' + sel.value); } }); })(input); } } else if (field.type === 'color' || field.type === 'color_var') { _renderColorField(group, field, value); panel.appendChild(group); Loading Loading @@ -794,6 +810,13 @@ var PropertiesPanel = (function() { if (mediaItem.url) { var srcInput = form.querySelector('input[name="src"]'); if (srcInput) srcInput.value = mediaItem.url; // Keep the "Format" dropdown in sync with the // file actually picked, so it doesn't keep // showing a stale default (e.g. "webp") for // the real extension of mediaItem.url. var extInput = form.querySelector('select[name="media_ext"]'); var extMatch = /\.([a-zA-Z0-9]+)$/.exec(mediaItem.url); if (extInput && extMatch) extInput.value = extMatch[1].toLowerCase(); } _seedNaturalSize(form, mediaItem.url); } Loading Loading
editor/html/js/properties.js +23 −0 Changes for editor/html/js/properties.js: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -512,6 +512,22 @@ var PropertiesPanel = (function() { if (value === field.options[j]) opt.selected = true; input.appendChild(opt); } // The "Format" dropdown (media_id-backed image/video widgets) and // the "src" text field are separate, independently-saved // properties. Without this, changing the format here leaves the // stored src pointing at the old extension, so the preview (and // the published page) keep serving the previous format. if (field.key === 'media_ext') { (function(sel) { sel.addEventListener('change', function() { var mediaIdInput = form.querySelector('input[name="media_id"]'); var srcInput = form.querySelector('input[name="src"]'); if (mediaIdInput && mediaIdInput.value && srcInput && sel.value) { srcInput.value = srcInput.value.replace(/\.[a-zA-Z0-9]+$/, '.' + sel.value); } }); })(input); } } else if (field.type === 'color' || field.type === 'color_var') { _renderColorField(group, field, value); panel.appendChild(group); Loading Loading @@ -794,6 +810,13 @@ var PropertiesPanel = (function() { if (mediaItem.url) { var srcInput = form.querySelector('input[name="src"]'); if (srcInput) srcInput.value = mediaItem.url; // Keep the "Format" dropdown in sync with the // file actually picked, so it doesn't keep // showing a stale default (e.g. "webp") for // the real extension of mediaItem.url. var extInput = form.querySelector('select[name="media_ext"]'); var extMatch = /\.([a-zA-Z0-9]+)$/.exec(mediaItem.url); if (extInput && extMatch) extInput.value = extMatch[1].toLowerCase(); } _seedNaturalSize(form, mediaItem.url); } Loading