Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Scandir */
- $thumbsDesignPath = "trabalhos/design/thumbs";
- $imagesDesignPath = "trabalhos/design/large";
- $file_display = array('jpg', 'jpeg', 'png', 'gif');
- if (file_exists($thumbsDesignPath) == false){
- echo 'Directory \'', $thumbsDesignPath, '\' not found.';
- } else {
- if (file_exists($imagesDesignPath) == false){
- echo 'Directory \'', $imagesDesignPath, '\' not found.';
- } else {
- $thumbs_content = scandir($thumbsDesignPath);
- $images_content = scandir($imagesDesignPath);
- $design_content = $thumbs_content + $images_content;
- echo '<pre>'; print_r($design_content); echo '</pre>';
- $counter = 0;
- $filesPerPage = 6;
- foreach ($design_content as $design_file)
- {
- $design_file_type = (end(explode('.', $design_file)));
- if($design_file !== '.' && $design_file !== '..' && in_array($design_file_type, $file_display) == true){
- if($counter == 0){
- echo "<li>";
- $counter++;
- /*$info = pathinfo($file);
- $sFile = basename($file,'.'.$info['extension']);
- $aFiles = glob($images.$sFile."[0-9]+.[".implode($file_display,"|")."]"); //This array shows all images relative to the thumbnail that you are seeing*/
- echo '<div class="portfolio_pic_hold"> <a href="'.$imagesDesignPath. '/' .$design_file.'" rel="lightbox[Design]"> <img src="'.$thumbsDesignPath. '/'.$design_file. '" /> </a> </div>';
- if($counter == $filesPerPage){
- echo "</li>";
- }
- }
- }
- }
- }
- }
- Result:
- Array
- (
- [0] => .
- [1] => ..
- [2] => pinheirinhonovo.jpg
- [3] => qclass.jpg
- [4] => sylviartz.jpg
- [5] => teresabrito.jpg
- [6] => tgi.jpg
- [7] => valoresremodelados.jpg
- [8] => videoclubebaviera.jpg
- [9] => xtremenutrition.jpg
- )
- /* Glob */
- $thumbsDesignPath = "trabalhos/design/thumbs/";
- $imagesDesignPath = "trabalhos/design/large/";
- $file_display = array('jpg', 'jpeg', 'png', 'gif');
- if (file_exists($thumbsDesignPath) == false)
- {
- echo 'Directory \'', $thumbsDesignPath, '\' not found.';
- }
- else
- {
- $thumbs = glob($thumbsDesignPath."*.[".implode($file_display,"|")."]");
- print_r($thumbs);
- if (file_exists($imagesDesignPath) == false){
- echo 'Directory \'', $imagesDesignPath, '\' not found.';
- } else
- {
- $counter = 0;
- $filesPerPage = 6;
- foreach ($thumbs as $file)
- {
- if($counter == 0) 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 class="portfolio_pic_hold"><a href="'. $imagesDesignPath. '/'. $file.'"> <img src="'. $thumbsDesignPath . '/' . $file . '" /> </a></div>';
- if($counter == $filesPerPage) echo "</li>";
- }
- }
- }
- Result:
- Array
- (
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement