A nicer mod_rewrite?

Hi all,

I was wondering if it is at all possible to get even nicer URL's in Zenphoto, as I am still not too keen on the way zenphoto is rewriting the urls at the moment.

The best thing for me would be to use the title of the image in the url. An example:

In stead of
http://www.thegirlinthecafe.com/photo2/new york/newyork005.jpg.php

I would love to have

http://www.thegirlinthecafe.com/photo2/new-york/123-times-square

(where 123 is the id of the image in the database, if at all needed)

I have this working on my photoblog (which is running pixelpost):

http://www.thegirlinthecafe.com/photoblog/160-london-marathon

and it works like a charm, google seems to love url's like that.

Has anybody tried this? Is this at all possible?

Thanks in advance for any help,
Ingrid

Comments

  • trisweb Administrator
    You're right, that's ideal for Google. I think it thinks they're more relevant, unlike names of php files. Then again, I get great hits on my galleries with the .php extension.

    Unfortunately it's not easily changed (at all) - the unique identifier to find the photo requested is the actual filename, and the only way to get that is from the URL, so it must contain the filename. That's just how ZP works, it's filesystem-based. The titles are rather stored in the database as metadata, which you can't use to get a photo and doesn't need to be unique.

    In future versions I'm planning on basing the framework on the database while keeping filesystem synced, instead of the other way around. That should allow more reference options in the URL. I'll make sure to keep that in mind in development..... if I ever have free time again after this startup gets off the ground.... :-(
  • Hi Tris

    Thanks for your answer, and I really appreciate your hard work.

    I am just too lazy to rename all my pictures so they have proper titles, that's why titles in my case would make more sense in the url than the filename. But it has to do for now I guess :)
  • Hello,

    Does Zenphoto now support nicer URLs ? It would be nice to have URLs like "/album/qName-of-the-photo" instead of "/abum/IMG4254.JPG".

    Without changing the way the framework is designed, maybe you can just add a field to rename the photo ? Or, better, automagically transform the title into a qualified name (space replaced by -, etc...), and add a checkbox under the title field like "Rename the file for 'qName-of-the-photo' ?".

    Thanks !
  • Why don't you just rename the images in FTP? Or, better still, start them off with the name you want.
  • Spaces, capitalization, special characters and so on in file names in the web are evil ;)
  • But, what has that got to do with the renaming of the image. If you don't want these characters in the name, don't put them there.
  • Well, if i create a blog entry in Wordpress “Süße Sahne (selbst gemacht)” (“sweet cream (selfmade)”), the URL will be “example.com/suesse-sahne-selbst-gemacht” :)
  • Maybe the i18n project will take this on.
  • To the original topic:

    I've taken this request on, and will get it worked out when I can. I might not get it done until after my current semester, though. My senior project comes first. (Yay wavelets!)
  • acrylian Administrator, Developer
    I see the problem with the spaces etc but for renaming the image to a proper title we have the admin backend.

    DirkSohler: But the difference to zenphoto is that wordpress is not file system based.

    sbillard: This is not really something that belongs to l18n, it's a general topic.

    Jsumners: No hurry, I have already sort of a function, that can do things like that, that needs a little refining.
  • Jep, it’s not fs based, and that is one of the reasons, why i switched to zenphoto!
  • sbillard, I can actually rename each file with the right name before posting them on Zenphoto, but it is not the best solution. I see to problem :

    1/ you have to set the title twice : first in the filename, second in the title field when you post the photo

    2/ even if I rename a "IMG1234.JPG" into "my-first-day-in-Berlin.jpg" for instance, there is still this ".jpg" that has no reason to be in the URL (cf http://www.w3.org/Provider/Style/URI). I want to remove this extension because with an album photo, you don't just give access to a photo file, you give access to a whole photo+title+comments+category+tags resource, which is more than a simple file, and so can't have any extension.

    That's why I suggested :

    1/ to have a checkbox in the form to add a photo that, if checked, generate a qualified name from the title (the way Wordpress does, cf DirkSohler comment), and rename the file this way. For instance, if I put "My first day in Berlin" as title, the file IMG1234.JPG I sent is renamed on the server as my-first-day-in-berlin.jpg

    2/ find a way (maybe with Apache content negociation or mod_rewrite) to use the URL /my-first-day-in-berlin, without the ".jpg"

    This way, Zenphoto would have very nice URLs, without changing the whole design (i.e. zp would still be FS based, and not DB based as Wp or other script can be).

    It would be great, I can't find a great photo album manager with nice URL...

    Thanks again for your work !
  • iriome:

    There is an option to add a image suffix, so you could use, say "view" and your file would show as "my-first-day-in-Berlin.jpg/view"

    If you put a title in your EXIF/IPTC data, it will be used as the zp title. Omitting the suffix on the filename that is on the server will cause all sorts of problems for zenphoto. That's the key it uses, for instance, to recognize images vs other files.

    Nothing is needed in mod_rewrite to omit the suffix. The problem is how to determin what the suffix should be. No suffix: then it is an album request. JPEG, JPG, GIF, PNG? FLV, 3GP, MOV?

    It would not be too hard for you to modify a theme to omit the suffix. But then every request will go to your albums.php file. It could then decide what to do.

    BTW, I am wondering how much of a problem this really is. Why are you looking at the URL anyway, the images should be the attraction of your album.
  • BTW, you do not have to do the rename twice. Just rename the image before the upload. ZP will use the image name (without the suffix) as the default title.
  • Update:

    You can modify the function zp_load_request() so that it will treat the last name in the list as the image name if you wish. Just add the .jpg suffix to what rewrite_get_album_image() returns as the image filename.
  • I didn't know about EXIF/IPTC title, wich soft handle this ? (I use digikam but i haven't seen this).

    I will try to create a maintenable hack for my problem.

    Thanks
  • Photoshop Bridge does a nice job of editing EXIF/IPTC data. I am sure there are other programs that do this as well.
  • Is it possible to remove the .jpg extension from the end of a url by using .htaccess
  • Hi and thanks for the reply - i am getting unusual results for urls - i have UTF8 image URIs and mod rewrite enabled

    the images are all going in with the same title format and displaying as follows

    Jen Akenyemi - Flowers Traditional.jpg
    Gerry Carnelly - Purple Octopus
    Gerry Carnelly - Siamese Fighting Fish

    http://www.tattoo.tv/gallery/colour/Jen-Akenyemi-Flowers-Traditional.jpg
    http://www.tattoo.tv/gallery/colour/Gerry+Carnelly+-+Purple+Octopus.jpg
    http://www.tattoo.tv/gallery/artists/Gerry Carnelly (Octopus Tattoo)/Gerry+Carnelly+-+Siamese+Fighting+Fish.jpg

    Thank you

    Steve
  • The URLs are, of course, based on the filenames, not the titles.
  • Thank you very much - that probably is the problem - is there a way through htaccess of changing the spaces to - as opposed to +
  • or a quick way of removing spaces in a folder ?
  • .htaccess would not help--you would have to change the file names. Don't know what platform you are on, but there is probably a file/folder renaming utility for it that would do the job. Remember to refresh the Zenphoto database once you do this. Also this may well cost the loss of any metadata you have entered through admin backend editing.
Sign In or Register to comment.