MCPcopy Create free account
hub / github.com/easydiffusion/easydiffusion / changePreviewImages

Function changePreviewImages

ui/media/js/image-modifiers.js:341–372  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

339}
340
341function changePreviewImages(val) {
342 const previewImages = document.querySelectorAll(".modifier-card-image-container img")
343
344 const previewArr = modifiers.flatMap((x) => x.modifiers.map((m) => m.previews))
345 .map((x) => x.reduce((obj, preview) => {
346 obj[preview.name] = preview.path
347
348 return obj
349 }, {}))
350
351 previewImages.forEach((previewImage) => {
352 const currentPreviewType = previewImage.getAttribute("preview-type")
353 const relativePreviewPath = previewImage.src.split(modifierThumbnailPath + "/").pop()
354
355 const previews = previewArr.find((preview) => relativePreviewPath == preview[currentPreviewType])
356
357 if (typeof previews == "object") {
358 let preview = null
359
360 if (val == "portrait") {
361 preview = previews.portrait
362 } else if (val == "landscape") {
363 preview = previews.landscape
364 }
365
366 if (preview) {
367 previewImage.src = `${modifierThumbnailPath}/${preview}`
368 previewImage.setAttribute("preview-type", val)
369 }
370 }
371 })
372}
373
374function resizeModifierCards(val) {
375 const cardSizePrefix = "modifier-card-size_"

Callers 1

image-modifiers.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected