diff options
author | Kellen <root@goodroot.ca> | 2017-12-23 07:52:02 +0300 |
---|---|---|
committer | Kellen <root@goodroot.ca> | 2017-12-23 07:52:02 +0300 |
commit | 53e51d95d14dcbea007e998f25adb88b3b0c36ec (patch) | |
tree | fbf23a3936d43cb2a982dff58a0001978eaff80f | |
parent | a4cd0b6fb5af2fa0beccf8e7102435ec4d8bca05 (diff) |
Removes dep
-rw-r--r-- | layouts/partials/foot_custom.html | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/layouts/partials/foot_custom.html b/layouts/partials/foot_custom.html index 00d4627..3d9fb1d 100644 --- a/layouts/partials/foot_custom.html +++ b/layouts/partials/foot_custom.html @@ -1,2 +1,25 @@ -<!-- Automagically centers images. --> -<script async src="//yihui.name/js/center-img.js"></script> +<!-- Automagically centers images. Original Author Yihui Xie: https://yihui.name --> +<script> +(function() { + function center_el(tagName) { + var tags = document.getElementsByTagName(tagName), i, tag; + for (i = 0; i < tags.length; i++) { + tag = tags[i]; + var parent = tag.parentElement; + // center an image if it is the only element of its parent + if (parent.childNodes.length === 1) { + // if there is a link on image, check grandparent + if (parent.nodeName === 'A') { + parent = parent.parentElement; + if (parent.childNodes.length != 1) continue; + } + if (parent.nodeName === 'P') parent.style.textAlign = 'center'; + } + } + } + var tagNames = ['img', 'embed', 'object']; + for (var i = 0; i < tagNames.length; i++) { + center_el(tagNames[i]); + } +})(); +</script> |