[gtk-web/new-website: 110/180] added js for changing image links



commit 4571cc3ff43c04495072511046e43bfb2fb255ef
Author: ravgeetdhillon <ravgeetdhillon gmail com>
Date:   Mon Jul 22 16:07:49 2019 +0530

    added js for changing image links

 _layouts/documentation.html | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/_layouts/documentation.html b/_layouts/documentation.html
index 95221bf..79fc38d 100644
--- a/_layouts/documentation.html
+++ b/_layouts/documentation.html
@@ -70,21 +70,20 @@
     $('[data-toggle="tooltip"]').tooltip();
   });
 
-  console.log(markdownImages);
+  // converts relative paths of markdown based images to absolute path
   var i, l, img, markdownImages;
   markdownImages = document.querySelectorAll("p img");
   l = markdownImages.length;
   for (i = 0; i < l; i++) {
     img = markdownImages[i]
     imgNodeValue = img.attributes.src.nodeValue;
-    if (imgNodeValue.search("https://";) == -1 || imgNodeValue.search("http://";) == -1) {
+    console.log(imgNodeValue);
+    if (imgNodeValue.search("https://";) == 0 || imgNodeValue.search("http://";) == 0) {
       continue;
     }
     else {
-      img.baseURI = "{{ site.url }}" + imgNodeValue;
+      img.setAttribute("src", "{{ site.url }}" + imgNodeValue);
     }
   }
-  console.log(markdownImages);
-
 </script>
 {% include footer.html %}
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]