问题跟踪图片附件和定义的样式不一时,调整图片缩略图显示方式
This commit is contained in:
parent
b5b50bef21
commit
bbe4c15293
|
@ -329,11 +329,12 @@ module ApplicationHelper
|
||||||
imagesize = attachment.thumbnail(:size => "200*200")
|
imagesize = attachment.thumbnail(:size => "200*200")
|
||||||
imagepath = named_attachment_path(attachment, attachment.filename)
|
imagepath = named_attachment_path(attachment, attachment.filename)
|
||||||
if imagesize
|
if imagesize
|
||||||
link_to image_tag(thumbnail_path(attachment), height: '73', width: '100'),
|
link_to image_tag(thumbnail_path(attachment), height: '73', width: '100', name: 'issue_attachment_picture'),
|
||||||
imagepath,
|
imagepath,
|
||||||
:title => attachment.filename
|
:title => attachment.filename
|
||||||
|
|
||||||
else
|
else
|
||||||
link_to image_tag(imagepath , height: '73', width: '100'),
|
link_to image_tag(imagepath , height: '73', width: '100', name: 'issue_attachment_picture'),
|
||||||
imagepath,
|
imagepath,
|
||||||
:title => attachment.filename
|
:title => attachment.filename
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,35 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.addEventListener('DOMContentLoaded',function(){
|
||||||
|
var img = document.getElementsByName('issue_attachment_picture');
|
||||||
|
function getImgNaturalStyle(img,callback) {
|
||||||
|
var nWidth, nHeight
|
||||||
|
if (typeof img.naturalWidth == "undefined"|| img.naturalWidth == 0) { // 现代浏览器
|
||||||
|
var image = new Image();
|
||||||
|
image.src = img.src;
|
||||||
|
nWidth = image.width;
|
||||||
|
nHeight = image.height;
|
||||||
|
} else {
|
||||||
|
nWidth = img.naturalWidth;
|
||||||
|
nHeight = img.naturalHeight;
|
||||||
|
}
|
||||||
|
return [nWidth, nHeight]
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0;i<img.length;i++)
|
||||||
|
{
|
||||||
|
imgNatural = getImgNaturalStyle(img[i]);
|
||||||
|
var width = imgNatural[0];
|
||||||
|
var height = imgNatural[1];
|
||||||
|
if (width<100)
|
||||||
|
{
|
||||||
|
img[i].width = width;
|
||||||
|
}
|
||||||
|
if (height<73) {
|
||||||
|
img[i].height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</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 %>
|
||||||
|
|
|
@ -87,7 +87,7 @@ a.pro_mes_w{ height:20px; float:left;display:block; color:#999999;}
|
||||||
.pro_page_top{ font-size:14px; border-bottom:2px solid #64bdd9; margin-bottom:10px; padding-bottom:5px;}
|
.pro_page_top{ font-size:14px; border-bottom:2px solid #64bdd9; margin-bottom:10px; padding-bottom:5px;}
|
||||||
.pro_page_tit{color:#3e4040; font-weight:bold;width:480px; float:left; font-size:14px; margin-bottom:5px;}
|
.pro_page_tit{color:#3e4040; font-weight:bold;width:480px; float:left; font-size:14px; margin-bottom:5px;}
|
||||||
.pro_pic_box{ margin-left:60px; }
|
.pro_pic_box{ margin-left:60px; }
|
||||||
.pro_pic{ width:100px; border:2px solid #CCC; margin:10px 0;}
|
.pro_pic{ width:100px; height:73px;line-height:73px;border:2px solid #CCC; margin:10px 0;}
|
||||||
.pro_info_box{ margin-left:60px; background:#f0fbff; height:80px; padding:10px 0;}
|
.pro_info_box{ margin-left:60px; background:#f0fbff; height:80px; padding:10px 0;}
|
||||||
.pro_info_box ul{}
|
.pro_info_box ul{}
|
||||||
.pro_info_box ul li{ margin-bottom:10px;}
|
.pro_info_box ul li{ margin-bottom:10px;}
|
||||||
|
|
Loading…
Reference in New Issue