Good afternoon everyone
There is a script that displays images from the specified folder, it copes well with this, but in this folder there are two types of images, a preview and an original, and they need to be displayed separately, you can help to separate them and display them
Previews start with thumb1.jpg, Original with page1.jpg
I need to display a gallery, like this:
<ul> ... <li><a href="page1.jpg"><img src="thumb1.jpg" alt="" /></a></li> <li><a href="page2.jpg"><img src="thumb2.jpg" alt="" /></a></li> <li><a href="page3.jpg"><img src="thumb3.jpg" alt="" /></a></li> ... </ul> Script itself
$directory = './wp-content/plugins/real3d-flipbook/books/flipbook1'; //Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΏΠ°ΠΏΠΊΠΈ Ρ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡΠΌΠΈ $allowed_types = array( 'jpg', 'jpeg', 'gif', 'png' ); //ΡΠ°Π·ΡΠ΅ΡΠ΅Π½ΡΠ΅ ΡΠΈΠΏΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ $file_parts = array(); $ext = ''; $title = ''; $i = 0; //ΠΏΡΠΎΠ±ΡΠ΅ΠΌ ΠΎΡΠΊΡΡΡΡ ΠΏΠ°ΠΏΠΊΡ $dir_handle = @opendir($directory) or die("There is an error with your image directory!"); while ($file = readdir($dir_handle)) //ΠΏΠΎΠΈΡΠΊ ΠΏΠΎ ΡΠ°ΠΉΠ»Π°ΠΌ { if ($file == '.' || $file == '..') continue; //ΠΏΡΠΎΠΏΡΡΡΠΈΡΡ ΡΡΡΠ»ΠΊΠΈ Π½Π° Π΄ΡΡΠ³ΠΈΠ΅ ΠΏΠ°ΠΏΠΊΠΈ $file_parts = explode('.', $file); //ΡΠ°Π·Π΄Π΅Π»ΠΈΡΡ ΠΈΠΌΡ ΡΠ°ΠΉΠ»Π° ΠΈ ΠΏΠΎΠΌΠ΅ΡΡΠΈΡΡ Π΅Π³ΠΎ Π² ΠΌΠ°ΡΡΠΈΠ² $ext = strtolower(array_pop($file_parts)); //ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Π΅Ρ - ΡΡΠΎ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ if (in_array($ext, $allowed_types)) { echo ' <img width="900" height="600" src="' . $directory . '/' . $file . '" class="attachment-slider wp-post-image" alt="img" title="img" />'; $i++; } } closedir($dir_handle); //Π·Π°ΠΊΡΡΡΡ ΠΏΠ°ΠΏΠΊΡ