Web Design Forum: image naming (with spaces?) - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

image naming (with spaces?) Rate Topic: -----

#1 User is offline   gordo 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 08-March 09
  • Reputation: 0
  • Experience:Beginner
  • Area of Expertise:Nothing

Posted 18 March 2010 - 08:58 AM

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!
0

#2 User is offline   Wickham 

  • Web Guru
  • View gallery
  • Group: Moderators
  • Posts: 2,875
  • Joined: 11-June 09
  • Reputation: 257
  • Gender:Male
  • Location:Salisbury UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 18 March 2010 - 09:12 AM

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/top...itespace-string
0

#3 User is offline   jnicol 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 52
  • Joined: 15-March 10
  • Reputation: 0
  • Gender:Male
  • Experience:Advanced
  • Area of Expertise:Web Designer

Posted 18 March 2010 - 09:37 AM

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
0

#4 User is offline   gordo 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 08-March 09
  • Reputation: 0
  • Experience:Beginner
  • Area of Expertise:Nothing

Posted 18 March 2010 - 10:56 AM

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users