March 18, 201016 yr Hi all I've built this photo site - www.ingridvekemans.com - from PHP and Javascript. The images are stored in a directory called 'Portfolio' and their info is stored in the database. My question is, how bad is it that the image names contain spaces? For example, an image name might be 'Two lions hunting.jpg'. It all works fine, but should it be 'Two_lions_hunting.jpg'? Or with hyphens? Thanks!
March 18, 201016 yr Spaces are not a good idea, but you can use a PHP function to fill or ignore the spaces. Do a search as I'm not sure which it is. This might help http://bytes.com/topic/php/answers/839-ignore-remove-whitespace-string
March 18, 201016 yr From a practical perspective it usually won't make a difference. However your pages may fail to validate. If for some reason you are unable to use hyphens or underscores instead of spaces when naming the files, you can use PHP's rawurlencode function to replace the spaces with %20, e.g: <?php echo rawurlencode('my file name.jpg'); ?> outputs: my%20file%20name.jpg
March 18, 201016 yr Author thanks both It does all work at the moment, but I want it to be as good as possible. I think a few hours' PHP can put in underscores, but before I do that, can I ask one more question? The site has only been online for a few weeks and Google's image bot hasn't swung by yet. If and when it does, do you know if there's any advantage/disadvantage to having spaces or underscores? I've read through the Google info but haven't found anything related... Gordon.
Create an account or sign in to comment