diff options
author | luxagraf <sng@luxagraf.net> | 2018-06-04 20:27:23 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-06-04 20:27:23 -0500 |
commit | 5a3d3d2e9d2ab67218144f7c2e35d70f47f9ad93 (patch) | |
tree | e57821443383b158e640d7afc8c2b40375c5c3cb /app/utils/static | |
parent | 8f4bbcbc391f318adb6eca5c538add126811feee (diff) |
converted jrnl entry to use image for featured image
Diffstat (limited to 'app/utils/static')
-rw-r--r-- | app/utils/static/image-loader.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/utils/static/image-loader.js b/app/utils/static/image-loader.js index 90054de..2b0a281 100644 --- a/app/utils/static/image-loader.js +++ b/app/utils/static/image-loader.js @@ -2,6 +2,36 @@ function add_images(){ var el = document.getElementById("id_body_markdown"); var iframe = '<iframe frameborder="0" style="border: #dddddd 1px solid;margin-left: 20px;width:330px; height:720px;" src="/luximages/insert/?textarea='+el.id+'"></iframe>'; el.insertAdjacentHTML('afterend', iframe); + + var featured_image = document.getElementById("id_featured_image") + + if (featured_image) { + featured_image.querySelectorAll('li').forEach(function(element) { + var cur = element.dataset.imageid + if (cur != "") { + var request = new XMLHttpRequest(); + request.open('GET', '/photos/luximage/data/admin/tn/'+cur+'/', true); + request.onload = function() { + if (request.status >= 200 && request.status < 400) { + var data = JSON.parse(request.responseText); + var el = element.getElementsByTagName('label')[0]; + url = "url('"+data['url']+"');"; + //console.log(url); + el.style.backgroundImage = 'url('+data["url"]+')'; + + //console.log(el.style); + } else { + console.log("server error", request.statusText); + } + }; + request.onerror = function() { + console.log("error on request"); + }; + request.send(); + } + }); + } + } document.addEventListener("DOMContentLoaded", function(event) { add_images(); |