我的博主Javascript一直让我的照片消失

时间:2014-10-12 18:41:49

标签: javascript image blogger

我最近添加了一个适合帖子宽度内所有图片的javascript代码。太好了!但它会导致我的图像在几秒钟后消失,留下破碎的图像图标。我怎样才能解决这个问题? 这是我添加到页面中的代码:

<script language='javascript'src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js' type='text/javascript'/>
 <script type='text/javascript'>//<![CDATA[
/**
this script was written by Confluent Forms LLC http://www.confluentforms.com
for the BlogXpertise website http://www.blogxpertise.com
any updates to this script will be posted to BlogXpertise
please leave this message and give credit where credit is due!
**/
$(document).ready(function(){
    // the dimension of your content within the columns
    var areawidth = $('#Blog1').width();
    $('.post-body').find('img').each(function(n, image){
        var image = $(image);
        var height = image.attr('height');
        var width = image.attr('width');
        var newHeight = (height/width * areawidth).toFixed(0);
        image.attr('width',areawidth).attr('height',newHeight);
        var greater = Math.max(areawidth,newHeight);
        image.attr({src : image.attr('src').replace(/s\B\d{3,4}/,'s' + greater)});
    });
});
//]]></script>

以下是我网站的链接:benjaminkristenreeves.blogspot.com

0 个答案:

没有答案