Fix images[0] undefined issue

Sometimes images is present but empty.
This commit is contained in:
DrJKL
2023-11-01 14:42:51 -07:00
parent 27555d4f71
commit 2e96d99079
+6 -4
View File
@@ -49,11 +49,13 @@ const ext = {
api.addEventListener("executed", ({ detail }) => { api.addEventListener("executed", ({ detail }) => {
if (!enabled) return; if (!enabled) return;
const images = detail?.output?.images; const images = detail?.output?.images;
if (!images) return; if (!images || !images.length) return;
const format = app.getPreviewFormatParam(); const format = app.getPreviewFormatParam();
const src = `/view?filename=${encodeURIComponent(images[0].filename)}&type=${ const src = [
images[0].type `/view?filename=${encodeURIComponent(images[0].filename)}`,
}&subfolder=${encodeURIComponent(images[0].subfolder)}&t=${+new Date()}${format}`; `type=${images[0].type}`,
`subfolder=${encodeURIComponent(images[0].subfolder)}`,
`t=${+new Date()}${format}`,].join('&');
show(src, detail.node); show(src, detail.node);
}); });