View Full Version : Image title in filename
When uploading a photo pixelpost allows you to add a timestamp to the file name.
i found this line in /admin/new_image.php
$filnamn = $time_stamp_r .$filnamn;
how would i add $image_title so that the filename also has the image title in it?
06-14-2007, 05:26 PM
$filnamn = $time_stamp_r .$filnamn.$image_title;
But be careful with spaces, comma's, exclamation points, double and single quotes, question marks, colon, semi-colon because that will not be handled by your filesystem.
06-14-2007, 08:36 PM
ow... did I mention I can't be hold responsible if your blog breaks?
06-15-2007, 02:55 AM
Because, as Schonhose stated, if your image title contains any spaces, comma's, exclamation points, double and single quotes, question marks, colon, semi-colon, ect, it is likely to break your blog as the filename does not accept most of these characters.
oh, i understand that.
but it seems that there is a problem. the image title is not included in the filename after the code has been modified.
06-15-2007, 05:14 AM
Try the following:
$filnamn = $time_stamp_r .$filnamn.$headline;
Well, that didnt quit do it, but i figured it out. If anyone's interested tell me and I'll explain what I did.
06-16-2007, 02:43 AM
I'm guessing there was more steps than just 1 line but $headline should have been the variable you were looking for.
Go ahead and explain to us all how you did this. I'm not particularly interested but other users may find this useful.
I added this to replace spaces with underscores and add an underscore to the end of the title:
$headline_r = str_replace(' ', '_', $headline) . '_';
Then added the new headline variable to $uploadfile
$uploadfile = $upload_dir .$time_stamp_r . $headline_r .$userfile;
and the same thing to $filnamn
$filnamn = $time_stamp_r . $headline_r . $filnamn;
06-16-2007, 07:46 PM
Yup, that works. Just be careful with the other special characters.
What's the reason you wanted the title in the file? Search results?
Yea, i noticed Google image results only worked for the photos where i manually put the title in the filename and I stopped doing that a while ago, so this should help.
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.