How can the code be modified to loop through all images in a specific folder and create thumbnails for each of them?

To loop through all images in a specific folder and create thumbnails for each of them, you can use the PHP `glob()` function to get an array of all image files in the folder. Then, you can iterate over this array and use a function like `imagecopyresampled()` to create thumbnails for each image.

<?php
$folder = 'path/to/folder/';
$files = glob($folder . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);

foreach ($files as $file) {
    $image = imagecreatefromstring(file_get_contents($file));
    $thumb = imagecreatetruecolor(100, 100);
    imagecopyresampled($thumb, $image, 0, 0, 0, 0, 100, 100, imagesx($image), imagesy($image));
    imagejpeg($thumb, $folder . 'thumb_' . basename($file), 80);
    imagedestroy($image);
    imagedestroy($thumb);
}
?>