2024-04-28, 02:22:04
Good morning
I have just developed a Regenerate Thumbnails plugin to allow you to regenerate all thumbnails of all uploaded images in your data/downloads folder and subfolder.
This is useful in situations such as:
The thumbnail size has changed and you want previous uploads to have a thumbnail of this size.
You've moved to a new GetSimple theme that uses thumbnail images of different sizes.
To free up space on the server, you can delete old, unused thumbnails from the data/thumbs folder and subfolder.
How can I share it with the GetSimple community?
If you find an error contact me!
I have just developed a Regenerate Thumbnails plugin to allow you to regenerate all thumbnails of all uploaded images in your data/downloads folder and subfolder.
This is useful in situations such as:
The thumbnail size has changed and you want previous uploads to have a thumbnail of this size.
You've moved to a new GetSimple theme that uses thumbnail images of different sizes.
To free up space on the server, you can delete old, unused thumbnails from the data/thumbs folder and subfolder.
How can I share it with the GetSimple community?
If you find an error contact me!
PHP Code:
<?php
/*
Plugin Name: regenerate_thumbnails
Description: regenerate thumbnails.
Version: 1.0
Author: jjancel 27/04/2024 15:00
Author URI: http://jjancel.free.fr/
*/
# get correct id for plugin
$thisfile=basename(__FILE__, ".php");
# register plugin
register_plugin(
$thisfile, # Plugin id
'Regenerate Thumbnails', # Plugin name
'1.0', # Plugin version
'jjancel', # Plugin author
'http://jjancel.free.fr/', # author website
'Regenerate Thumbnails', # Plugin description
'files', # page type of plugin
'regenerate_thumbnails_show' # main plugin function
);
# activate filter
add_action('files-sidebar','createSideMenu',array($thisfile,'Regenerate Thumbnails'));
# functions
function regenerate_thumbnails_show() {
if (isset($_POST['submitted'])) {
echo '<h3>list of all images in the data/uploads folder and subfolders</h3>';
$uploaddir = '../data/uploads';
listFolderFiles($uploaddir);
}
echo '<h3>How use Regenerate Thumbnails on your files?</h3>';
echo "<p>Regenerate Thumbnails allows you to regenerate all thumbnails for all uploaded images in your data/uploads folder and sub folder.</p> <p>This is useful in situations such as:</p> <ul> <li>The thumbnail size has changed and you want previous uploads to have a thumbnail of this size.</li> <li>You've moved to a new GetSimple theme that uses thumbnail images of a different size.</li> </ul> <p>In order to free up space on the server you can delete old, unused thumbnails from the data/thumbs folder and sub folder.</p>";
echo '<form method="post" action="';
echo $_SERVER["PHP_SELF"];
echo '?id=regenerate_thumbnails"> <input type="submit" name="submitted"/> </form>';
}
# functions thumbnails
function frmtFolder($Entity) {
echo '<li style="font-weight:bold;color:black;list-style-type:none">'.$Entity;
}
function frmtFile($dEntry, $fEntry) {
if (preg_match('/(\.gif|\.jpg|\.jpeg|\.png|\.webp)$/i', $fEntry)) {
$subFolder = substr($dEntry, 16).'/';
echo '<li style="list-style-type:square">'.'<a href="'.$dEntry.'/'.$fEntry.'"> '.$fEntry.' </a><br>';
// generate thumbnail
require_once('inc/imagemanipulation.php');
genStdThumb($subFolder,$fEntry);
}
}
function listFolderFiles($dir) {
$ffs = scandir($dir);
unset($ffs[array_search('.', $ffs, true)]);
unset($ffs[array_search('..', $ffs, true)]);
unset($ffs[array_search('index.html', $ffs, true)]);
// prevent empty ordered elements
if (count($ffs) < 1) {return;}
echo '<ul>';
foreach ($ffs as $ff) {
if (is_dir($dir . '/' . $ff)) {
frmtFolder($dir);
} else {
frmtFile($dir, $ff);
}
if (is_dir($dir . '/' . $ff)) {
listFolderFiles($dir . '/' . $ff);
}
echo '</li>';
}
echo '</ul>';
}
?>