Overview

let title = dv.current().name || dv.current().file.name;
let lowerTitle = title.toLowerCase();
 
// Extract nickname inside quotes if present (e.g. Rolo "Shorty" Cutter -> shorty)
let matchNick = title.match(/"([^"]+)"/);
let nickname = matchNick ? matchNick.toLowerCase() : null;
 
let match = app.vault.getFiles().find(f => {
  if (!f.path.toLowerCase().includes("npc-images")) return false;
  let imgName = f.name.toLowerCase();
  return (
    imgName.includes(lowerTitle) ||
    (nickname && imgName.includes(nickname))
  );
});
 
if (match) {
    dv.paragraph(`![[${match.path}|cover]]`);
} else {
    dv.paragraph(`*No artwork generated yet for ${title}*`);
}

Character Bio

A soldier of House von Scholtz that is assigned to serve Gideon.

Appearance & Personality