2016-04-26 57 views

回答

0

我已经与原来的灯箱制作我自己的脚本一起 http://lokeshdhakar.com/projects/lightbox2/ 决定了它会快得多这样:

 <?php 
      echo str_replace(array('<','>'), array('&lt;','&gt;'),'<table id="galx"><tr>'); 
      $source_dir = 'images/taken/from/here'; 
      $mini_dir = 'mini'; 
      $target_dir = 'imagies/copied/to/there'; 
      $i=0; 

      $images = array_diff(scandir($source_dir), array('..', '.',$mini_dir)); 
      foreach($images as $image) 
      { 
       $filename = pathinfo($image, PATHINFO_FILENAME); 
       $title = mb_strtoupper(trim(str_replace('_',' ',$filename))); 
       $s = "<td><a href='$target_dir/$image' data-lightbox='galx' data-title='$title' >" 
         . "<img src='$target_dir/$mini_dir/$filename.jpg' /><br/>" 
         . "$title<a/></td>"; //gallery with titles 
       /*$s = "<td><a href='$target_dir/$image' data-lightbox='galx' >" 
         . "<img src='$target_dir/$mini_dir/$filename.jpg' />" 
         . "<a/></td>";*/ //gallery without titles 

       if (++$i % 5 == 0) 
        $s .= '</tr><tr>'; 

       $s = str_replace(array('<','>'), array('&lt;','&gt;'), $s); //comment this line if want to paste it as php code 
       echo $s; 
      } 
      echo str_replace(array('<','>'), array('&lt;','&gt;'),'</tr></table>'); 
     ?> 

一些基本的CSS:

#galx { 
    width: 650px; 
} 

#galx td { 
    text-align: center; 
} 

#galx a { 
    display: block; 
    width: 120px; 
    font-size: 0.8em; 
    margin:1px auto; 
    text-decoration: none; 
    color: black; 
    text-align: center; 
} 

我用FastStone图像查看器批量调整图像的大小并创建缩略图。在应用程序中,只需按F3即可打开高级处理工具。

它只是不适用于Windows上的非英文字母 - PHP的错误。它仍然会破坏Linux上第一个非英文字母的文件名,所以在这种情况下需要在前缀'_'。

总体良好的结果 - 我已经隐藏脚本在网站上的某个地方,并在1.5小时内生成6个画廊〜1,5k图片,大部分时间被文件处理和复制消耗。不优雅但有效。