Hi, I just tried folderblog for the first time tonight. Seems pretty nifty! One thing I found, after uploading a bunch of pics from my 7MP digicam is that they don't get scaled down :( So I threw together a little hack to get them to!
The basic idea is that along with the thumbs folder, you have another folder to hold the resized photos. Here are the modifications that i made to beta3:
fb_settings.php
--------------------
AT the end of the file ADD:
$image_maxsize = 660; // Maximum dimensions for a displayed image (in pixels)
$photo_resize_directory = "photoresize/"; // Directory for resized photos
fb.php
--------------------
BEFORE function createThumb ADD:
function createImage($filename,$altname="") { //MODIFIED
global $photo_resize_directory, $image_directory, $image_maxsize, $file_extension;
$original = imagecreatefromjpeg($filename);
$x = imagesx($original);
$y = imagesy($original);
$scale = $image_maxsize/max($x, $y);
$newx = $x*$scale;
$newy = $y*$scale;
$image_resize = imagecreatetruecolor($newx, $newy);
imagecopyresampled($image_resize, $original, 0, 0, 0, 0, $newx, $newy, $x, $y);
imagejpeg($image_resize, $photo_resize_directory . basename($filename), 95);
if ($altname) {
imagejpeg($image_resize, $photo_resize_directory . $altname, 95);
}
return array($newx, $newy);
}
REPLACE function getDirList WITH:
function getDirList($index) {
global $fbfile, $include_cats, $categories, $photo_directory, $photo_resize_directory, $file_extension, $post, $sort; //MODIFIED
if ($index=="image") {
$index = "";
} else {
$index .= "/";
}
$index_directory = $photo_directory . $index;
$filelist = glob("$index_directory*$file_extension", GLOB_NOSORT);
if (($include_cats==1) && (!$index) && ($categories)) {
foreach($categories as $subdir) {
if ($content = glob("$subdir/*$file_extension", GLOB_NOSORT)) {
$filelist = array_merge($filelist, $content);
}
}
}
isset($filelist[0]) or die("<html><body>folderblog error
</h1>No image files found in $index_directory. Please upload files or confirm directory location and permissions.</body></html>");
while($filename = array_pop($filelist)) {
$base = basename($filename, $file_extension);
if (filesize($filename)==0) {
$thiscat = "";
$folders = array_merge(array(rtrim($photo_directory, "/")), $categories);
while(!@filesize("$thiscat/$base$file_extension") && ($folders)) {
$thiscat = array_shift($folders);
}
$filename = "$thiscat/$base$file_extension";
}
if ($post||filemtime($filename)<=time()) {
$files[$filename] = $base;
}
}
if ($sort==1) {
natcasesort($files);
}
else {
uksort($files,"cmpmtime");
}
$files = array_unique($files);
foreach($files as $key => $thisfile) { //MODIFIED THIS LOOP
$image_resize_file = "$photo_resize_directory{$thisfile}$file_extension";
if ((!file_exists($image_resize_file)) && (function_exists("imagejpeg"))) {
createImage($key);
}
if (file_exists($image_resize_file)) {
$clean[] = array($thisfile, $image_resize_file);
}
else {
$clean[] = array($thisfile, $key);
}
}
return $clean;
}
posted by Enki1337 on 29 Mar 06 at 3:48 AM

