织梦dede后台缩略图阅览图片效果选择缩略图

最近客户想要后台预览之前的图片库的图片,于是记录下
具体操作步骤:文件位置
找到织梦 根目录 include/dialog 目录下的文件,
select_images.php 用DW打开进行编辑

第一步:找到style 标签 修改 style样式为 如下:
目的是为了引入JS悬浮代码和调整悬浮层的样式代码。

再 head 标签上面加了一个 query 鼠标跟随 显示图片的JS 以确保 图片始终跟随 鼠标 显示。

第二部:搜索 endloop 这个词 再下面加上如下JS代码 位置一定要放在这里。控制显示缩略图
}//End Loop
$dh->close();
?>

第三部:现在要修改的就是图片路径URL 文字的主要标签代码, 修改代码如下。直接复制替换就好。

   $line = "\n<tr>

    如此,大功告成!主要是修改了 UL标签的class 类,来明确鼠标再哪里划过会显示出缩略图层预览,方便找到之前的图片 完整代码如下

    /**
     * 图片选择框
     */
    require_once(dirname(__FILE__)."/config.php");
    include(DEDEDATA.'/mark/inc_photowatermark_config.php');
    if(empty($activepath))
    {
        $activepath = '';
    }
    if(empty($imgstick))
    {
        $imgstick = '';
    }
    $noeditor = isset($noeditor)? $noeditor : '';
    $activepath = str_replace('.', '', $activepath);
    $activepath = preg_replace("#\/{1,}#", '/', $activepath);
    if(strlen($activepath) < strlen($cfg_medias_dir))
    {
        $activepath = $cfg_medias_dir;
    }
    $inpath = $cfg_basedir.$activepath;
    $activeurl = '..'.$activepath;
    
    
    if(empty($f))
    {
        $f = 'form1.picname';
    }
    if(empty($v))
    {
        $v = 'picview';
    }
    if(empty($comeback))
    {
        $comeback = '';
    }
    $addparm = '';
    if (!empty($CKEditor))
    {
        $addparm = '&CKEditor='.$CKEditor;
        $f = $CKEditor;
    }
    if (!empty($CKEditorFuncNum))
    {
        $addparm .= '&CKEditorFuncNum='.$CKEditorFuncNum;
    }
    
    if (!empty($noeditor))
    {
        $addparm .= '&noeditor=yes';
    }
    ?>
    <html>
    <head>
    <meta http-equiv='Content-Type' content='text/html; charset=<?php echo $cfg_soft_lang; ?>'>
    <title>图片浏览器</title>
    <link href='../../plus/img/base.css' rel='stylesheet' type='text/css'>
    <style>
    .linerow {border-bottom: 1px solid #CBD8AC;}
    .bb {width:150px;height:100px;position:absolute;z-index:3;display:none;}
    </style>
    <script>
    function nullLink(){ return; }
    function ChangeImage(surl){ document.getElementById('picview').src = surl; }
    </script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script>
    function nullLink(){ return; }
    function ChangeImage(surl){ document.getElementById('picview').src = surl; }
    </script>
    </head>
    <body background='img/allbg.gif' leftmargin='0' topmargin='0'>
    <div id="floater" class="napisdiv">
    <a href="javascript:nullLink();" onClick="document.getElementById('floater').style.display='none';"><img src='img/picviewnone.gif' id='picview' border='0' alt='单击关闭预览'></a>
    </div>
    <SCRIPT language=JavaScript src="js/float.js"></SCRIPT>
    <SCRIPT language=JavaScript>
    function nullLink(){ return; }
    function ChangeImage(surl){ document.getElementById('floater').style.display='block';document.getElementById('picview').src = surl; }
    function TNav()
    {
    	if(window.navigator.userAgent.indexOf("MSIE")>=1) return 'IE';
      else if(window.navigator.userAgent.indexOf("Firefox")>=1) return 'FF';
      else return "OT";
    }
    // 获取地址参数
    function getUrlParam(paramName)
    {
      var reParam = new RegExp('(?:[\?&]|&amp;)' + paramName + '=([^&]+)', 'i') ;
      var match = window.location.search.match(reParam) ;
      return (match && match.length > 1) ? match[1] : '' ;
    }
    
    function ReturnImg(reimg)
    {
        var funcNum = getUrlParam('CKEditorFuncNum');
    	if(funcNum > 1)
    	{
    		var fileUrl = reimg;
    		window.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl);
    	}
    	if(window.opener.document.<?php echo $f?> != null)
    	{
    		window.opener.document.<?php echo $f?>.value=reimg;
    		if(window.opener.document.getElementById('div<?php echo $v?>'))
    	    {
    		 if(TNav()=='IE'){
    			 //window.opener.document.getElementById('div<?php echo $v?>').filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = reimg;
    			 window.opener.document.getElementById('div<?php echo $v?>').src = reimg;
    			 window.opener.document.getElementById('div<?php echo $v?>').style.width = '150px';
    			 window.opener.document.getElementById('div<?php echo $v?>').style.height = '100px';
    		 }
    		 else
    			 window.opener.document.getElementById('div<?php echo $v?>').style.backgroundImage = "url("+reimg+")";
    	  }
    		else if(window.opener.document.getElementById('<?php echo $v?>')){
    			window.opener.document.getElementById('<?php echo $v?>').src = reimg;
    		}
    		if(document.all) window.opener=true;
    	}
    	
        window.close();
    }
    </SCRIPT>
    <table width='100%' border='0' cellspacing='0' cellpadding='0' align="center">
    <tr>
    <td colspan='4' align='right'>
    <table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#CBD8AC'>
    <tr bgcolor='#FFFFFF'>
    <td colspan='4'>
    <table width='100%' border='0' cellspacing='0' cellpadding='2'>
    <tr bgcolor="#CCCCCC">
    <td width="8%" align="center" class='linerow' bgcolor='#EEF4EA'><strong>预览</strong></td>
    <td width="47%" align="center" background="img/wbg.gif" class='linerow'><strong>点击名称选择图片</strong></td>
    <td width="15%" align="center" bgcolor='#EEF4EA' class='linerow'><strong>文件大小</strong></td>
    <td width="30%" align="center" background="img/wbg.gif" class='linerow'><strong>最后修改时间</strong></td>
    </tr>
    <tr>
    <td class='linerow' colspan='4' bgcolor='#F9FBF0'>
    点击“V”预览图片,点击图片名选择图片,显示图片后点击该图片关闭预览。
    </td>
    </tr>
    <?php
    $dh = dir($inpath);
    $ty1="";
    $ty2="";
    while($file = $dh->read()) {
    
        //-----计算文件大小和创建时间
        if($file!="." && $file!=".." && !is_dir("$inpath/$file")){
            $filesize = filesize("$inpath/$file");
            $filesize = $filesize / 1024;
            if($filesize != "")
            if($filesize < 0.1){
                @list($ty1, $ty2) = split("\.", $filesize);
                $filesize = $ty1.".".substr($ty2, 0, 2);
            }
            else{
                @list($ty1, $ty2) = split("\.", $filesize);
                $filesize = $ty1.".".substr($ty2, 0, 1);
            }
            $filetime = filemtime("$inpath/$file");
            $filetime = MyDate("Y-m-d H:i:s", $filetime);
        }
    
        if($file == ".") continue;
        else if($file == "..")
        {
            if($activepath == "") continue;
            $tmp = preg_replace("#[\/][^\/]*$#i", "", $activepath);
            $line = "\n<tr>
       <td class='linerow' colspan='2'>
       <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode($tmp).$addparm."'><img src=img/dir2.gif border=0 width=16 height=16 align=absmiddle>上级目录</a></td>
       <td colspan='2' class='linerow'> 当前目录:$activepath</td>
       </tr>
       ";
            echo $line;
        }
        else if(is_dir("$inpath/$file"))
        {
            if(preg_match("#^_(.*)$#i", $file)) continue; #屏蔽FrontPage扩展目录和linux隐蔽目录
            if(preg_match("#^\.(.*)$#i", $file)) continue;
            $line = "\n<tr>
       <td bgcolor='#F9FBF0' class='linerow' colspan='2'>
       <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode("$activepath/$file").$addparm."'><img src=img/dir.gif border=0 width=16 height=16 align=absmiddle>$file</a></td>
       <td class='linerow'> </td>
       <td bgcolor='#F9FBF0' class='linerow'> </td>
       </tr>";
            echo "$line";
        }
        else if(preg_match("#\.(gif|png)#i", $file))
        {
            $reurl = "$activeurl/$file";
            $reurl = preg_replace("#^\.\.#", "", $reurl);
            if($cfg_remote_site=='Y' && $remoteuploads == 1)
             {
               $reurl  = $remoteupUrl.$reurl;
            }else{
                $reurl = $reurl;
            }
    
            if($file==$comeback) $lstyle = " style='color:red' ";
            else  $lstyle = "";
    
            $line = "\n<tr>
       <td align='center' class='linerow' bgcolor='#F9FBF0'>
       <a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='img/picviewnone.gif' width='16' height='16' border='0' align=absmiddle></a>
       </td>
       <td class='linerow' bgcolor='#F9FBF0'>
       <a href=# οnclick=\"ReturnImg('$reurl');\" $lstyle><img src=img/gif.gif border=0 width=16 height=16 align=absmiddle>$file</a></td>
       <td class='linerow'>$filesize KB</td>
       <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
       </tr>";
    
            echo "$line";
        }
        else if(preg_match("#\.(jpg)#i", $file))
        {
            $reurl = "$activeurl/$file";
            $reurl = preg_replace("#^\.\.#", "", $reurl);
            if($cfg_remote_site=='Y' && $remoteuploads == 1)
             {
               $reurl  = $remoteupUrl.$reurl;
            }else{
                $reurl = $reurl;
            }
    
            if($file==$comeback) $lstyle = " style='color:red' ";
            else  $lstyle = "";
    
            $line = "\n<tr>
       <td align='center' class='linerow' bgcolor='#F9FBF0'>
       <a href=\"#\" onClick=\"ChangeImage('$reurl');\"><img src='img/picviewnone.gif' width='16' height='16' border='0' align=absmiddle></a>
       </td>
       <td class='linerow' bgcolor='#F9FBF0'>
       <ul class='zz'><a href=# onMouseOver=\"ChangeImage('$reurl');\" οnclick=\"ReturnImg('$reurl');\" $lstyle><img src=img/jpg.gif border=0 width=16 height=16 align=absmiddle>$file</a></ul>
       </td>
       <td class='linerow'>$filesize KB</td>
       <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td>
       </tr>";
            echo "$line";
        }
    }//End Loop
    $dh->close();
    ?>
    <script type="text/javascript">
        $('.bb').hide();
        $('.zz').mousemove(function(e){
            $('.bb').eq($(this).index()).show().css({
                "top": e.pageY+20,
                "left": e.pageX+20
            }).siblings("div").hide();
        });
        $('.zz').mouseleave(function(){
            $('.bb').hide();
        });
    </script>
    <tr>
    <td colspan='4' bgcolor='#E8F1DE'>
    
    <table width='100%'>
    <form action='select_images_post.php' method='POST' enctype="multipart/form-data" name='myform'>
    <?php $noeditor = !empty($noeditor)?"<input type='hidden' name='noeditor' value='yes'>":''; echo $noeditor;//(2011.08.25 根据用户反馈修正图片上传回调 by:织梦的鱼)?>
    <input type='hidden' name='activepath' value='<?php echo $activepath?>'>
    <input type='hidden' name='f' value='<?php echo $f?>'>
    <input type='hidden' name='v' value='<?php echo $v?>'>
    <input type='hidden' name='imgstick' value='<?php echo $imgstick?>'>
    <input type='hidden' name='CKEditorFuncNum' value='<?php echo isset($CKEditorFuncNum)? $CKEditorFuncNum : 1;?>'>
    <input type='hidden' name='job' value='upload'>
    <tr>
    <td background="img/tbg.gif" bgcolor="#99CC00">
      &nbsp;上 传: <input type='file' name='imgfile' style='width:250px'/>
      <input type='checkbox' name='needwatermark' value='1' class='np' <?php if($photo_markup=='1') echo "checked"; ?> />水印
      <input type='checkbox' name='resize' value='1' class='np' />缩小
      宽:<input type='text' style='width:30' name='iwidth' value='<?php echo $cfg_ddimg_width?>' />
      高:<input type='text' style='width:30' name='iheight' value='<?php echo $cfg_ddimg_height?>' />
      <input type='submit' name='sb1' value='确定' />
    </td>
    </tr>
    </form>
    </table>
    
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>
    
    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值