%[if publish]% Your directory of \''. $dir. '\' could not be found! No images could be seen or used by ProGallery. Please carefully check the relative path is correct. Your hosting company might be able to help you.
'; } else { $dir_contents = scandir($dir); foreach ($dir_contents as $file) { // Ignore images that have '@2x' or 'thumb_' in the name - we can replace these files later with our own prefixes / calls. if (strpos($file, '_thumb') === false && strpos($file, '@2x') === false) { $file_type = strtolower(end(explode('.', $file))); $file_display[$file] = filemtime($dir . '/' . $file); $filetitle = $file; // Generate 'cleaned' image titles, with no hyphens or underscores %[if %("%id=strip_hyphens%" == "true")% ]%$filetitle = str_replace("-", " ", $filetitle);%[endif]% %[if %("%id=strip_underscores%" == "true")% ]%$filetitle = str_replace("_", " ", $filetitle);%[endif]% %[if %("%id=strip_extensions%" == "true")% ]%$filetitle = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filetitle);%[endif]% // Have some 'thumb' file names ready as variables, in case we need them a bit later $extension_pos = strpos($file, '.'); // Find position of the last dot, so where the extension starts $thumbnail = substr($file, 0, $extension_pos) . '_thumb' . substr($file, $extension_pos); // Have some 'retina' file names ready as variables, in case we need them a bit later $extension_pos = strpos($file, '.'); // Find position of the last dot, so where the extension starts $retina = substr($file, 0, $extension_pos) . '@2x' . substr($file, $extension_pos); arsort($files); if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) { echo('This ProGallery source can be configured it to read image files (jpg, jpeg, png, bmp, svg and webp) from a directory (folder) on your web server. ProGallery will take the images it finds within the directory and display them within the gallery. Image file names will be sanitised (hyphens, underscores and file extensions are removed) and reused as titles. Any images added or removed from the directory are immediately updated on your website, without requiring a republish from RapidWeaver. This ProGallery source can read files from any public-facing directory, including Total CMS folders / depots, Pulse media folders or a FileMan directory; therefore making it a powerful and very versatile image source that can be successfully integrated into many other solutions.
Under normal circumstances, this ProGallery source will ignore any images that contain _thumb
in their file name (e.g. forest_thumb.jpg) or @2x
in their file name (e.g. forest@2x.jpg). In these instances, your regular images will be used for both the thumbnail grid and lightbox. However both thumbnail images and high-resolution retina images can be made to work in this image source, if you have them available for ProGallery:
_thumb
appended onto the end of the file name (e.g. worldwide_thumb.jpg). These thumbnail images will then get used in your thumbnail grid. Thumbnail images can be smaller than the normal images you use, to promote faster page loading and reduced bandwidth.@2x
appended onto the end of the file name (e.g. worldwide@2x.jpg). These high resolution images will only be used in the lightbox viewing mode, on retina displays (non-retina displays will use the standard resolution images). Retina images remain at 72 dpi, but are double the width and height of your standard images.In both instances, it is important that these named image files are always available in your image directory; if you choose to enable thumbnails or retina images. Otherwise you may see thumbnail or retina images missing in the gallery. Normally thumbnail and retina images can all be grouped together within the same directory. ProGallery will look at your image file names and know what to use for each part of the gallery.
What is a relative path? PHP is a server-side programming language and can't interpret normal web links in the same way you see them. This is partly done for improved security and faster performance. The webpage that the PHP code runs on (in other words the page you put ProGallery on) is known as the current working directory. If your ProGallery page is not located on the homepage of the website AND the image directory is not in the same working directory as ProGallery, you will need to provide a more concise relative path to the image directory. Lots of information about relative paths can be found online. In essence, you enter ../
to step-back however many directory levels is required, towards the website homepage. Then you can specify the path to the directory hosting your images. A possible example of a relative path to your directory of images might look like ../../uploads/gallery
.
Don't forget that the file extension of this webpage will need changing to .php in the RapidWeaver Page Inspector. If you previously published this page with a .html extension, you will need to login to your hosting account via FTP and delete the old page. HTML takes precedence over PHP, and if conflicting pages exist in the current working directory, only the older HTML version will show.
It is not possible to preview this image source in RapidWeaver. Please publish this page to MAMP or an actual web server, to test it.
If you want a method to login and upload or delete images from your preferred directory, we recommend the free FileMan stack.