folderblog
What is folderblog?
Folderblog is a free PHP script that automatically displays the images placed in a given directory, no database needed. It can be used as a blog or gallery — and anything in between.

» demo blog   » learn more   » download now

Discussion
resizing photos(back to index)
for those of you who want to automatically resize the photos in the template....
if you're using relaxation, change the line34 in relaxation_main.php like this (max width to 600) :

<img src="<#fbimageurl#>" alt="<#fbtitle#> : <#fbdate#>" width =<?php echo min(600, <#fbwidth#>); ?> height=<?php if (<#fbwidth#> > 600) {echo <#fbheight#>*600/<#fbwidth#>;} else {echo <#fbheight#>;}; ?> usemap="imgmap" />
posted by stephane on 5 Nov 05 at 4:35 PM
It would be better to resize the dimension of the image using gd, rather than squeeze the image.

Also I encountered two errors with this:
1. you need to put quotes around the height and width values:
<img src="<#fbimageurl#>" alt="<#fbtitle#> : <#fbdate#>" width ="<?php echo min(600, <#fbwidth#>); ?>" height="<?php if (<#fbwidth#> > 600) {echo <#fbheight#>*600/<#fbwidth#>;} else {echo <#fbheight#>;}; ?>" usemap="imgmap" />

2. this resize doesn't work well with the fotobuzz extension that relaxation uses
posted by geoff on 8 Nov 05 at 5:11 PM
So... may I take this as a request for a new function in folderblog which enables automatic image resizing during the upload? ;)
posted by ikue on 9 Nov 05 at 2:32 AM
please do; i was thinking of taking a crack at it but I'm not sure when I'll get the time :)
posted by geoff on 9 Nov 05 at 2:42 AM
and for those of you who play with the relaxation theme and want to squeeze your photos until a proper resizer is built, here's the line I use that will turn on or off depending on whether the fotobuzz script is present or not: [line 34 in my copy of relaxation_main.php]
<img '; } else {?> src="<#fbimageurl#>" alt="<#fbtitle#> : <#fbdate#>" width ="<?php echo min(600, <#fbwidth#>); ?>" height="<?php if (<#fbwidth#> > 600) {echo <#fbheight#>*600/<#fbwidth#>;} else {echo <#fbheight#>;}; ?>" usemap="imgmap" /> <? } ?>
posted by geoff on 9 Nov 05 at 2:47 AM
bah..I either made a mistake or it's getting cut by some evil filter: <img '; } else {?> src="<#fbimageurl#>" alt="<#fbtitle#> : <#fbdate#>" width ="<?php echo min(600, <#fbwidth#>); ?>" height="<?php if (<#fbwidth#> > 600) {echo <#fbheight#>*600/<#fbwidth#>;} else {echo <#fbheight#>;}; ?>" usemap="imgmap" /> <? } ?>
posted by geoff on 9 Nov 05 at 2:49 AM
<img '; } else {?> src="<#fbimageurl#>" alt="<#fbtitle#> : <#fbdate#>" width ="<?php echo min(600, <#fbwidth#>); ?>" height="<?php if (<#fbwidth#> > 600) {echo <#fbheight#>*600/<#fbwidth#>;} else {echo <#fbheight#>;}; ?>" usemap="imgmap" /> <? } ?>
posted by geoff on 9 Nov 05 at 2:50 AM
obviously I can't post the code for some reason. If someone would kindly delete this and the previous two comments for posterity's sake. And how about a method to post code without it disappearing?
<?php if (file_exists('..<#fbdir#>fotobuzz/fotobuzz.php')) { echo 'class="fotobuzz" src="<#fbimageurl#>" alt="<#fbtitle#> : <#fbdate#>" width="<#fbwidth#>" height="<#fbheight#>" usemap="imgmap" />'; } else {?> src="<#fbimageurl#>" alt="<#fbtitle#> : <#fbdate#>" width ="<?php echo min(600, <#fbwidth#>); ?>" height="<?php if (<#fbwidth#> > 600) {echo <#fbheight#>*600/<#fbwidth#>;} else {echo <#fbheight#>;}; ?>" usemap="imgmap" /> <? } ?>
posted by geoff on 9 Nov 05 at 2:53 AM
that figures..the last post included the line i wanted to provide..which is a poor method anyhow :-/
but it wasn't working becuase the I'm not sure why it screwed things up by following img with php open tags, but that's what's happened and I've made a mess of this thread. :(
posted by geoff on 9 Nov 05 at 2:56 AM
Okay, I included a quite comprehensive and nice function which will do the job!

check the post of new folderblog ikue release 1.5!
posted by ikue on 9 Nov 05 at 3:33 AM
I'm unable to get your script to work. I've tried a few fresh installs, both on my local and web server and all I get is a blank page. I've tried removing parts of fb.php that you customized and it hasn't worked yet.
I like some of the customizations you made but dont need them all. At this point all I'd like to do is plug a few of them in.
posted by geoff on 9 Nov 05 at 4:00 PM
ok here's what I've learned:
your version doesnt work with alt_urls on. I can get it to work if I use that.

also, my idea of how this function would work is that it would take all the source image files and create a folder of resized images just as the thumbs are created. Then, fb would use the resized folder for all displaying of images. Even images that are not too large would be copied, but not resized. The source image folder could then be deleted. Either the fb script could check automatically if there are new images in the source folder, or there should be an admin button for 'check for new source images'.
It would also be welcome if caption files were automatically created in the same way, taking the date from the image file and the option whether to take the title from the filename or not.
Obviously, those who are really cramped for disk space on their server may not want this functionality, nor do people who have no need or desire to resize their images by a server script.
posted by geoff on 9 Nov 05 at 4:19 PM
ikue

this may be my problem I have use alt_urls on... I'll see if I can use fb without it...
posted by Richard Hendrix on 9 Nov 05 at 5:22 PM
@Geoff: I understand your idea, but I dont think that the functionality you described makes sense to be included into folderblog. There are several reasons why not, e.g. adding unnecessary complexity to a script by functions which dont belong to its "core competence" (displaying images) is never good if it can be done better.

It would be far more logical if you create a separate script that does exactly what you request: Copies all the unresized, big images from a source folder on your webserver to the photos folder of folderblog. You can also easily add the creation of captions with date etc this way, you even have the existing source code already done by me - just copy and modify it.

@Richard: True, this might be as I never use this option and therefore dont do any debugging on it. I also never really dealt with it, is it that necessary?
posted by ikue on 10 Nov 05 at 2:14 AM
@ikue: yep, I know I don't necessarily come up with ideas that everyone would generally want their folderblog to do, and don't presume these functions should become the core of folderblog.

I will try to get folderblog to do what I said, I mention it here only to gauge any interest in it, to see if others want it or have tips.

@Richard: I can perhaps help you if you're having trouble getting fb to run with alt_urls off -- even on the dreaded DreamHost with php as cgi running.

I prefer the look of the file.php/dir/dir as opposed to file.php?p=/dir/dir but perhaps you or others prefer the opposite. I'd suppose there'd be some way to make ikue's functions to work with it, if necessary, but I don't imagine it is.

@ikue: I'd also like to know how to get ikue 1.5 to run without the fb_exif_extended.php extension present. I don't need or want it but it fails without it. Eventually I'll have time and get into the grits of your script but it would be appreciated if you had some documentation on how to remove some of your functions. All in good time.
posted by geoff on 10 Nov 05 at 4:09 AM
@Geoff: You only get the error message when you enable the automatic resizing function, and if you dont care that during resizing the EXIF information is lost, look yourself into the script at the bottom of it. All the functions I add are well-documented as far as possible.
posted by ikue on 10 Nov 05 at 4:22 AM
my apologies as I don't mean to be fussy or aggressive. But I'm not finding what you mean by at the bottom of it. At the bottom of fb.php? I don't find anything in what I downloaded from your site. Perhaps I'm missing something.

And what error message do I get with the resizing enabled? Are you referring to the alt_urls problem -- because that just causes a blank screen.
posted by geoff on 10 Nov 05 at 4:27 AM
if (!isset($exifextended_loaded)) { showerror("Please include the fb_exif_extended.php in your extensions directory to use the automatic resize function. This is necessary to transfer all EXIF information."); }
is the error message you should get when using resizing without the library.

alt_urls has nothing to do with this according to my information.

The relevant EXIF lines you have to look for start at the comment "//load old EXIF data"
posted by ikue on 10 Nov 05 at 4:38 AM
no..it doesn't give any error. Just a blank page. and the same happens whether or not $resize_on_upload is set to true or false or whether it's on my web server that needs mod_rewrite or my local server that doesn't.
Perhaps there is a problem with your error message generator? I'm just fishing for possibilities. If I get time to dig in to this, I'll try to be more helpful.

I tried commenting out the entire
if (@$resize_on_upload) {..}
and it worked with the fb_exif_extended.php extension present but not without it.

posted by geoff on 10 Nov 05 at 5:29 AM
further, everything works without fb_exif.php but not the extended script and not without both. hope this puzzler doesn't drive you nuts. any other cases of success or failure of your script out there?
posted by geoff on 10 Nov 05 at 5:35 AM
an unrelated problem (perhaps, I think) that occurs only with my web server, as it runs with php as cgi and exif is not enabled.
I'd get an error of an undefined function from PHP but only for image files that contained exif information. The error was
Fatal error: Call to undefined function: exif_imagetype() in /../../fb.php on line 154

If you want to discover if you have this problem, check your phpinfo: '--with-exif' = no exif || '--enable-exif' = with exif
Replacing your createThumb function with the original one solves this problem.
It does not however, change anything regarding the extended extension problem and I have been testing on a local server with exif and a web server without, getting the same result. Both PHP 4.3.10
posted by geoff on 10 Nov 05 at 6:14 AM
The new folderblog ikue release is optimized for usage with both fb_exif.php and fb_exif_extended.php enabled. Individual versions for those whose servers dont support EXIF in general can be quite easily created with minimum understanding of PHP programming. I will not have the time to recode the whole sources, but I am sure somebody here has the skills to do it. If you get error messages about, just comment out the extensions made in lines with EXIF signatures.
posted by ikue on 10 Nov 05 at 6:49 AM
Found the core of the exif_extended problem. Your error generator for it, [if (!isset($exifextended_loaded)) ..] needs a tweak.

-First, $exifextended_loaded is never set whether the extension is loaded or not.
-Second, the error-checking line is in a bad spot. It needs to get out of the conditional statements.
-Third, the line used to include the extension has errors suppressed, hence my blank screens and blank expressions at trying to work this. Instead of using @require_once("extensions/fb_exif_extended.php");
this will work with your error system:
 
if (is_file("extensions/fb_exif_extended.php")) {
$exifextended_loaded = 1;
include_once("extensions/fb_exif_extended.php");
}

see the link on my name for where i got this method.
posted by geoff on 10 Nov 05 at 10:28 AM
Nice, will be added in the folderblog ikue 1.6. Thanks
posted by ikue on 10 Nov 05 at 10:36 AM
Have you compiled a list of the settings relevant to your script anywhere?

You may also want to consider suggesting that those who don't want exif_extended should not put it in their include file and can set set $exifextended_loaded = 1; provided that they are using fb ikue 1.6
posted by geoff on 10 Nov 05 at 11:34 AM
I dont understand what you exactly suggest.

And what do you mean by a list of the settings? You mean the extensions which can be activated in fb_settings.php? You find everything in this post, just look above.
posted by ikue on 10 Nov 05 at 1:24 PM
ikue

yes for fb to run on my server I need to use the alt_urls on.

geoff, I would be interested in how to work around this if you have any suggestions I will guinea pig it for you! :-) I am using NetFirms and I think they use the php as cgi type servers...
posted by Richard Hendrix on 10 Nov 05 at 1:57 PM
Ok Richard, starting a new topic for this.
posted by geoff on 10 Nov 05 at 5:12 PM
ikue: re: my suggestion for checking for exif_extended

perhaps it is more elegant to use something like the fb handling of the fb_exif.php check, using php's extension_loaded() function to check for exif.
 
if (extension_loaded('exif') &&
is_file("extensions/fb_exif_extended.php")) {...

..and for true elegance, we should only need to check for exif once, perhaps using a variable like $got_exif to handle any and all exif requests in fb.
posted by geoff on 10 Nov 05 at 7:21 PM
although I feel it's unlikely anyone will find this info down here who is looking for it, I want to point out that if you're using the relaxation theme, it has an error in the code that prevents IE from using the image map properly.

Also, this will allow me to post the code that I was screwing up this page with above.

To create an autoresizing photo that also fixes the missing # in the imgmap tag for relaxation theme:
<img  if (file_exists('..<#fbdir#>fotobuzz/fotobuzz.php')) 
{ echo 'class="fotobuzz" src="<#fbimageurl#>"
alt="<#fbtitle#> : <#fbdate#>" width="<#fbwidth#>"
height="<#fbheight#>" usemap="#imgmap" />'; }
else {?>
src="<#fbimageurl#>" alt="<#fbtitle#> :
<#fbdate#>" width ="<?php echo min(600,
<#fbwidth#>); ?>" height="
<?php if (<#fbwidth#> > 600) {
echo <#fbheight#>*600/<#fbwidth#>;}
else { echo <#fbheight#>;}; ?>"
usemap="#imgmap" /> <? } ?>

IE 6 only understands #imgmap but Firefox understood both. Relaxation theme also removes the name="imgmap" from the map tag used in the default template but I haven't noticed this makes a difference.
posted by geoff on 12 Nov 05 at 12:14 AM
As a response to the issue about how to check for the extended exif library, I included the function get_included_files as it handles exactly this. Avoiding a variable like $got_exif.
posted by ikue on 12 Nov 05 at 9:43 AM
Post a Reply:

Name:    Remember me
URL:    
(include http:// or mailto:)
(back to index)