replace spaces with underscores in albums url

Hi

Is there a way to replace the spaces in the urls with underscores. Where I have albums with more than one word there is a space (%20) in the url which is causing a problem with a place I am connecting to.

For example http://freepixelz.com/Celebrations/Baby_Shower/bat1-05975.JPG instead of http://freepixelz.com/Celebrations/Baby Shower/bat1-05975.JPG

Thanks

Stuart

Comments

  • acrylian Administrator, Developer
    The seo_zenphoto plugin if enabled will clean album folder names and filenames if created respectively uploaded via the backend for standard ASCII chars which includes replacing spaces with dashes. Underscores are not replaced though as they are fine already.

    The seo_cleanup plugin allows doing this cleaning afterwards but since it uses above plugin underscores are not changed. You would have to create your own plugin version to change that.
  • Dashes is fine. I'll try that.

    If no more message it means it worked....

    Many thanks!
  • Hi acrylian

    That worked fine on my test site but on my main site it failed, maybe due to timeout as I have 35,000 images.

    My image names are fine as they don't have spaces so it is only the albums that I need to fix so looks like I have to do it on the database.

    I see there is a field called 'folder' in the the 'albums' table which will need changing but is there anything else? how about the htaccess file or zenphoto-rewrite.txt file?

    Thanks for your help.

    Stuart
  • I tried changing one of the album records in the database from 'outer space' to 'outer-space' and after looking at the pages in the browser the database changed back to 'outer space' so I take it there must be something else to do.
  • fretzl Administrator, Developer
    Since Zenphoto is file system based you can't use the database to change (physical) file/folder names on the server.

    If you want to do this only once you could try to temporarily edit the file zp-core/zp-extensions/seo_cleanup.php

    Comment(or remove) lines 109-133.
    This causes only albums/subalbums to be processed and maybe then the server won't timeout.
    Be sure to revert to the original zp-core/zp-extensions/seo_cleanup.php file afterwards.

    You may still get a warning on the backend that the file has been changed. If so, run setup again.
  • acrylian Administrator, Developer
    @stuartmiles: Might have been a time out but you should look into your server PHP error log to be sure about that. It also could be a file/folder permissions issue or something else.

    We'll take a look to add a plugin option so you can at least choose to clean images and/or albums.
  • Hi fretzl and acrylian

    I started making copies of the folders then adding hyphens and just changing the album titles but the hosting went down so I quit for the day...

    I have decided to change to cloud hosting and will have to upload everything again so I think I will add hyphens to the folders before uploading which should be easier to sort out.

    I will still keep the hosting as a backup so will try running the cleanup file with those lines commented out.

    Thanks again for all of your help :-)
  • acrylian Administrator, Developer
    Note if you change the folder names without using those backend tools you might loose album data.

    If you for example entered titles, descriptions, added tags etc. after uploading those albums all will be gone as a new folder name means new album (same for images). Zenphoto matches the database to the file system not the other way round.

    If that is not a problem for you then fine of course.
  • I was duplicating the folder and adding dashes so it was treating it as a new album then I deleted the old so it worked out ok.

    Thanks

    Stuart
  • acrylian Administrator, Developer
    Okay, just that step wouldn't have been necessary as changing the folder name on the file sytems means new album for Zenphoto already. The only possible issue is data entered via the backend afterwards as that would get lost this way in any case.
Sign In or Register to comment.