Commit e6e14440 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_corporate_identity: wait for image to be loaded

otherwise naturalWidth/naturalHeight may be 0
parent e9b98429
...@@ -39,15 +39,13 @@ Creates the Book header. ...@@ -39,15 +39,13 @@ Creates the Book header.
var y = document.getElementsByClassName(x[i]); var y = document.getElementsByClassName(x[i]);
for (var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]]; for (var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
} }
var z = document.getElementsByClassName("hack"); }
for (var k=0; k<z.length; ++k) { function setImageSize(pic) {
var pic = z[k]; if (pic.naturalWidth / pic.naturalHeight <= 1) {
if (pic.naturalWidth / pic.naturalHeight <= 1) { pic.style.width = "auto";
pic.style.width = "auto"; pic.style.maxWidth = "28mm";
pic.style.maxWidth = "28mm"; pic.style.maxHeight = "28mm"
pic.style.maxHeight = "28mm" pic.style.height = "auto";
pic.style.height = "auto";
}
} }
} }
</script> </script>
...@@ -65,7 +63,7 @@ Creates the Book header. ...@@ -65,7 +63,7 @@ Creates the Book header.
<tr> <tr>
<td> <td>
<div class="ci-book-header-image-wkhtmltopdf-image-wrapper"> <div class="ci-book-header-image-wkhtmltopdf-image-wrapper">
<img class="hack" tal:attributes="src python: book_logo_url; alt python: book_logo_title"/> <img class="hack" onload="setImageSize(event.srcElement)" tal:attributes="src python: book_logo_url; alt python: book_logo_title"/>
</div> </div>
</td> </td>
<td> <td>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment