-1

PHP と jQuery は初めてですが、easySlider と Lightbox プラグインを使用して開発しているポートフォリオに対して次のことを行いたいと考えています。

  1. 「li」タグごとに 6 つの画像または 6 つの div 画像の制限を表示し、ディレクトリから閉じます。

    • ディレクトリに 6 つ以上の画像がある場合は、新しい「li」タグを作成し、そのディレクトリのすべての画像が読み込まれるまで、さらに 6 つの画像を表示します。

    • 画像の名前の後に番号が付いている場合 -> 表示: 非表示。例: beta1 ですが、最初の "beta" だけを表示したい

    • 画像を名前順に並べ替えます。

  2. コード自体でない場合は、そのディレクトリの画像に誰もアクセスさせないでください。

ポートフォリオのコードは次のとおりです。

<div id="portfolio_hold">
   <ul>

     <li>
      <div class="portfolio_pic_hold">

        <a href="large.jpg" rel="lightbox[]" >
          <img src="thumb.jpg"/>
        </a>

      </div>
     </li>

   </ul>
</div>

これは、私が見せたいもののhtmlの例です。

4

1 に答える 1

0

これでうまくいくかもしれません

$thumbsPath = "trabalhos/design/thumbs/";
$imagespath = "trabalhos/design/images/";
$file_display = array('jpg', 'jpeg', 'png', 'gif');

if (file_exists($thumbsPath) == false)
{
    echo 'Directory \'', $thumbsPath, '\' not found.';
}
else
{
    $thumbs = glob($thumbsPath."*.[".implode($file_display,"|")."]");
    if (file_exists($imagesPath) == false){
            echo 'Directory \'', $imagesPath, '\' not found.';
    } else
    {
            $counter = 0;
            $filesPerPage = 6;
            foreach ($thumbs as $file)
            {
                    if($counter % $filesPerPage) echo "<li>";
                    $counter++;
                    $info = pathinfo($file);
                    $sFile =  basename($file,'.'.$info['extension']);

                    $aFiles = glob($images.$sFile."[0-9]+.[".implode($file_display,"|")."]"); //Este array tem todas as imagens relativas ao thumbnail que estás a ver
                    echo "<div><img /></div>";
                    if($counter == $filesPerPage) echo "</li>";
            }
    }
}
于 2012-05-30T10:58:06.080 に答える