« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/upd8.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-xsrc/upd8.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/upd8.js b/src/upd8.js
index 1447118..13cf2e7 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -606,6 +606,7 @@ function stringifyThings(thingData) {
 function img({
     src,
     alt,
+    noSrcText = '',
     thumb: thumbKey,
     reveal,
     id,
@@ -620,7 +621,7 @@ function img({
     const willLink = typeof link === 'string' || link;
 
     const originalSrc = src;
-    const thumbSrc = thumbKey ? thumb[thumbKey](src) : src;
+    const thumbSrc = src && (thumbKey ? thumb[thumbKey](src) : src);
 
     const imgAttributes = html.attributes({
         id: link ? '' : id,
@@ -630,10 +631,13 @@ function img({
         height
     });
 
-    const nonlazyHTML = wrap(`<img src="${thumbSrc}" ${imgAttributes}>`);
-    const lazyHTML = lazy && wrap(`<img class="lazy" data-original="${thumbSrc}" ${imgAttributes}>`, true);
+    const noSrcHTML = !src && wrap(`<div class="image-text-area">${noSrcText}</div>`);
+    const nonlazyHTML = src && wrap(`<img src="${thumbSrc}" ${imgAttributes}>`);
+    const lazyHTML = src && lazy && wrap(`<img class="lazy" data-original="${thumbSrc}" ${imgAttributes}>`, true);
 
-    if (lazy) {
+    if (!src) {
+        return noSrcHTML;
+    } else if (lazy) {
         return fixWS`
             <noscript>${nonlazyHTML}</noscript>
             ${lazyHTML}