问题跟踪附件图片显示不拉伸

memcached_alan
whimlex 10 years ago
parent 33fc193e65
commit 538ba33174

@ -1,23 +1,49 @@
<script type="text/javascript"> <script type="text/javascript">
document.addEventListener('DOMContentLoaded',function(){ document.addEventListener('DOMContentLoaded',function(){
var img = document.getElementsByName('issue_attachment_picture'); var img = document.getElementsByName('issue_attachment_picture');
function getImgNaturalStyle(img,callback) {
var nWidth, nHeight
if (typeof img.naturalWidth == "undefined"|| img.naturalWidth == 0) { // 现代浏览器 function getImgNaturalStyle(img, callback) {
var nWidth, nHeight;
if (typeof img.naturalWidth == "undefined"|| img.naturalWidth == 0) {
var image = new Image(); var image = new Image();
image.src = img.src; image.src = img.src;
nWidth = image.width; if (image.complete) {
nHeight = image.height; callback(image);
} else { } else {
nWidth = img.naturalWidth; image.onload = function () {
nHeight = img.naturalHeight; callback(image);
image.onload = null;
};
};
} }
return [nWidth, nHeight] else
{
if (img.complete) {
nWidth = img.naturalWidth;
nHeight = img.naturalHeight;
} else {
img.onload = function () {
nWidth = img.naturalWidth;
nHeight = img.naturalHeight;
image.onload = null;
};
};
}
return [nWidth, nHeight];
} }
function UpdateImageInformation(image) {
return [image.width,image.height];
}
for(i=0;i<img.length;i++) for(i=0;i<img.length;i++)
{ {
imgNatural = getImgNaturalStyle(img[i]); imgNatural = getImgNaturalStyle(img[i],UpdateImageInformation);
var width = imgNatural[0]; var width = imgNatural[0];
var height = imgNatural[1]; var height = imgNatural[1];
if (width<100) if (width<100)
@ -29,7 +55,10 @@
} }
} }
}); });
</script> </script>
<div class="attachments" style="font-weight:normal;"> <div class="attachments" style="font-weight:normal;">
<% is_float ||= false %> <% is_float ||= false %>
<% for attachment in attachments %> <% for attachment in attachments %>

Loading…
Cancel
Save