CJ 1 vuosi sitten
vanhempi
commit
c2a31e0c02

+ 14 - 10
templates/blog.html

@@ -115,15 +115,6 @@
             font-weight: 300;
         }
 
-        p > a > img {
-            width: 100%;
-            height: 100%;
-        }
-
-        p > img {
-            width: 100%;
-            height: 100%;
-        }
 
         .pre {
             background-color: antiquewhite;
@@ -250,11 +241,24 @@
     });
     let imgs = $('#article').find('p>img')
 
+    function getClass(width) {
+        if (width > 35 && width < 150) {
+            return 'ui small rounded image'
+        } else if (width > 150 && width < 600) {
+            return 'ui medium rounded image'
+        } else if (width > 600) {
+            return 'ui fluid rounded image'
+        }
+    }
+
     for (let i = 0; i < imgs.length; i++) {
         if ($(imgs[i]).attr('alt')) {
             let alt = $(imgs[i]).attr('alt')
             let src = $(imgs[i]).attr('src')
-            $(imgs[i]).parent().html(`<a data-pswp-width="${alt.split(',')[0]}" data-pswp-height="${alt.split(',')[1]}" href="${src}"><img width="${alt.split(',')[0]}" height="${alt.split(',')[1]}" data-magnify="gallery" data-src="${src}"  src="${src}"  data-href="${src}" "/></a>`)
+            $(imgs[i]).parent().html(`<a data-pswp-width="${alt.split(',')[0]}" data-pswp-height="${alt.split(',')[1]}" href="${src}"><img  class="${getClass(alt.split(',')[0])}" width="${alt.split(',')[0]}" height="${alt.split(',')[1]}" data-magnify="gallery" data-src="${src}"  src="${src}"  data-href="${src}" "/></a>`)
+        } else {
+            let src = $(imgs[i]).attr('src')
+            $(imgs[i]).parent().html(`<img  class="ui fluid rounded image"  src="${src}" />`)
         }
     }
     var lightbox = new PhotoSwipeLightbox({

+ 1 - 1
templates/management/article/edit_article.html

@@ -220,7 +220,7 @@
            if (alt === undefined || alt === null || alt === '') {
                 return `<img src="${src}" alt="${alt}">`
             } else {
-                return `<img  alt="${alt}"   src="${src}" "/>`
+                return `<img  alt="${alt}"   src="${src}"/>`
             }
         }
     };

+ 1 - 1
templates/management/article/new_article.html

@@ -210,7 +210,7 @@
             if (alt === undefined || alt === null || alt === '') {
                 return `<img src="${src}" alt="${alt}">`
             } else {
-                return `<img  alt="${alt}"   src="${src}" "/>`
+                return `<img  alt="${alt}"   src="${src}"/>`
             }
         }
     };