当前位置:  首页>>建站教程>>discuz教程
广告合作

discuz如何解决手机端图片显示模糊

2020-09-14 20:22:09      站长源码库      769      0

discuz如何解决手机端图片显示模糊,最终实现的效果图


5f5f6177165fd.png



实现多图上传

修改文件upload/template/default/touch/forum/post.htm 83行代码

修改内容:添加multiple属性

<li style="padding:0px;">
   <a href="javascript:;" class="y" style="background:url(static/image/mobile/images/icon_photo.png) no-repeat;overflow:hidden;">
      <input type="file" name="Filedata" multiple="multiple" id="filedata" style="width:30px;height:30px;font-size:30px;opacity:0;">
   </a>
</li>

修改js文件upload/template/default/touch/forum/post.htm 206行

修改内容:直接复制过去即可 

for (var i=0;i<this.files.length;i++ ) {
    var file_data = [];
    file_data.push(this.files[i]);
    $.buildfileupload({
        uploadurl:'misc.php?mod=swfupload&operation=upload&type=image&inajax=yes&infloat=yes&simple=2',
        files:file_data,
        uploadformdata:{uid:"$_G[uid]", hash:"<!--{eval echo md5(substr(md5($_G[config][security][authkey]), 8).$_G[uid])}-->"},
        uploadinputname:'Filedata',
        maxfilesize:"2000",
        success:uploadsuccess,
        error:function() {
            popup.open('上传失败,请稍后再试', 'alert');
        }
    });
}

 

测试多图上传:这个时候就已经实现了多图上传了


5f5f61edaff63.png


图片大图显示

修改文件upload/template/default/touch/forum/discuzcode.htm 90行

修改内容:把83改为330

$fix = count($post[imagelist]) == 1 ? 140 : 330;

修改完效果:对于上面的这个330应该就是显示图片的宽度的。但是这是在一个机器里边测试的,其他机型肯定有问题。而且图片已经模糊的不能看了。


5f5f622231b07.png


图片高质量显示

我们打开pc端,发现pc端的图片竟然用的是原图


5f5f6245c568f.png


在看看移动端的图片发现图片的显示规则使用他自己的规则,这个规则后边咔咔会在写到


5f5f6268508ae.png


移动端的图片显示质量真是让人堪忧啊!

修改文件upload/template/default/touch/forum/viewthread.htm 174行-183行修改为

<!--{if $_G['forum_thread']['subjectImage']}-->
<!--{loop $_G['forum_thread']['subjectImage'] $imageData}-->
<img src="data/attachment/forum/$imageData[attachment]" alt="">
<!--{/loop}-->
<!--{/if}-->

修改PHP文件upload/source/module/forum/forum_viewthread.php:在20行后加上即可

 

# 主题图片

$subjectImage = DB::fetch_all("select * from pre_forum_attachment where tid= '$tid' limit 1");
$subject_tableId = $subjectImage[0]['tableid'];
$subjectData = DB::fetch_all("select attachment from pre_forum_attachment_$subject_tableId where tid= '$tid'");
$thread['subjectImage'] = $subjectData;


 然后实现最终效果


5f5f62cfac60f.png


TAGdiscuz
评论(0)条