Workaround for the fact Jekyll generates ALT attributes for <img> entries into of TITLE attributes.

This commit is contained in:
Martin Taillefer 2017-05-04 21:53:25 -07:00
parent 679beb4a8b
commit c4797866bd
3 changed files with 21 additions and 2 deletions

View File

@ -39,7 +39,7 @@ There are 3 versions of the reviews microservice:
The end-to-end architecture of the application is shown below.
![Bookinfo application without Istio](./img/bookinfo/noistio.svg)
![BookInfo application without Istio](./img/bookinfo/noistio.svg)
This application is polyglot, i.e., the microservices are written in different languages.
@ -156,7 +156,7 @@ This application is polyglot, i.e., the microservices are written in different l
http://104.196.248.114:8088/dotviz). After the single `curl` request from an earlier step,
the resulting image will look something like:
![Bookinfo service graph](./img/bookinfo/servicegraph.png)
![BookInfo service graph](./img/bookinfo/servicegraph.png)
The servicegraph should show very low (or zero) QPS values, as only a single request has been sent. The
service uses a default time window of 5 minutes for calculating moving QPS averages. Send a consistent

View File

@ -77,6 +77,7 @@ layout: compress
<script src="{{home}}/js/waves.js"></script>
<script src="{{home}}/js/buttons.js"></script>
<script src="{{home}}/js/search.js"></script>
<script src="{{home}}/js/fixMarkdownImages.js"></script>
{% if page.customjs %}
<script async="" defer="" type="text/javascript" src="{{ page.customjs }}"></script>

18
js/fixMarkdownImages.js Normal file
View File

@ -0,0 +1,18 @@
// Jekyll's markdown processor attaches ALT attributes to <img> elements.
// That's a bug, it really should be attaching TITLE attributes instead.
// This script grovels the DOM and assigns a TITLE attribute if one is not
// present by cloning the ALT attribute.
(function(){
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var img = images[i];
var title = img.getAttribute("title");
if (title == undefined) {
title = img.getAttribute("alt");
if (title != undefined) {
img.setAttribute("title", title);
}
}
}
})();