how do I drop the ".JPG" from image page url ?

Hello,

how do I get the url rewriting to display

album_name/image_name.jpg/mri_suffix

into >>

album_name/image_name/mri_suffix

Help appreciated, I've already tried to look at the code myself but I fear that I might break things, thank you in advance :)

Comments

  • something like this would probably do the trick (?)

    $search = array('.jpg', '.png', '.gif');
    $replace = array('');
    $filename = str_replace($search, $replace, $filename);

    yet I'm not sure where to include this :)

    thank you !
  • I was hoping there would be an answer to this :)
    I know the extensions serve file type purposes etc.. but couldn't this be an option?

    The url bellow
    http://pictor.us/canvas/natural/allegra.jpg/closer
    I think would look better like this
    http://pictor.us/canvas/natural/allegra/closer

    the jpg seems extra (?)

    I would be appreciative to help in this case, I think maybe a hack for this would be extensive so even if it isn't easy I would appreciate a reply saying so.

    Thanks for all the hard work guys :]
  • If you are using the community build already, go into your Admin Options tab and change Mod_rewrite Image suffix to be blank. Otherwise change it in your zp-config file.
  • trisweb Administrator
    motaheri - It isn't possible to remove the .jpg because it would make conflicts between different files. I do understand that you want the option if you're using only .jpg files, but we can't assume that for everyone.

    Also, you are correct, the hack would be relatively difficult. There are many places where the filename is used as the ID to reference different things and we can't change them all.

    Hopefully the image suffix gives you a good enough solution.

    Please submit this as a ticket in Trac, and give it a milestone of 1.2. From there we'll discuss and consider it. Thanks!
  • @ aitf311,
    thanks alot, wow.. I hadn't noticed the options page was made into a tab - really good move! I must say this beats editing the file manually and uploading it; really simplified!

    @ trisweb,
    Hello! Thanks for the thorough explanation.. really means a great deal to me!
    yeah, I guessed (after looking at the code) that the file extension is pretty well buried into a lot of things - tho I wasn't sure if there was a line they all pointed to; or if... thanks for the clarification.. yes, I understand that ZP now support more file types and images are the only the main concern.. I am a greedy url person xD lol

    _Hopefully the image suffix gives you a good enough solution._

    yes, with the mri_suffix I like how the pages once ending with .jpg are not anymore confused with image files..

    _Please submit this as a ticket in Trac, and give it a milestone of 1.2. From there we'll discuss and consider it._

    that sounds wonderful!
    haha.. lots of generosity from you guys!

    I wonder how... this will work.. since as you mentioned it determines a lot of things.
    WordPress handles similar 'pretty urls' by doing the same thing Vista does (with files) and firefox does (with downloads) lol.. adding a "-2" to the string.. and since WordPress uses dates as pre-url extensions.. the "-2" is actually very highly unlikely; keeping everything clean.

    Maybe I am thinking.. if there was an "option" for the photoblog type user only to default the file type to "jpeg | png | other" the variable would fall out of needing to be determined, since it has already been determined by the option before, saving the requirement to have the extension in the url. Also maybe the video file extension could be isolated by slashes.. ie, file-name/video/

    I really don't know! just ideas

    rawr.. I wrote a lot. sorry for that. I'll find the the Trac and mention it there
    =)

    Cheers!

    mo
  • I would like to revive the request for this. I saw that it is a ticket in trac, but it was slated for v1.2 and not finished for it.

    This is incredibly important for me, as I'm trying to switch from Gallery2, which allowed me to strip the .jpg off. I don't want to have to redirect the old URLs to new URLs, as that will take time for search engines to get up to speed on the changes.

    That, and I've noticed a lot of people try just copying the URL with a .jpg in it (anywhere in the URL) and embedding that on their site or myspace.

    Is there any update on this? Or, could someone guide me to where the internals are for finding the files and returning the URLs so that I could just strip off the .jpg, as all of my files will always have the extension .jpg.
  • acrylian Administrator, Developer
    It is not possible to do this at the moment because the way Zenphoto works: http://www.zenphoto.org/2008/08/troubleshooting-zenphoto/#30
  • You could make .htaccess changes to add the .jpg to the image name. But of course, the rub is you will need some way to tell the difference between `album/image` and `album/album2`
  • I was unsure if I had to start a new topic since this one is pretty old.

    My question concerns the mod_rewrite suffix, is anything changed in the meanwhile?
    I would love to remove .jpg but I guess I can accept different solution like swap .jpg with .html, I know I can add .html but a name page .jpg.html is very bad from a SEO point of view.

    Also adding a "/folder" at the end seems to be really a bad choice for crawlers, and makes no sense for the crawlers.

    I would really like to have the suffix swapping or removing, maybe in the last two years something changed, I didn't find any reference to that function, I could also try to modify that by myself!

    A suggestion would be having the image.php generates a id/ instead than filename.jpg or whatever, choosing to have as page name "id, filename, or whatever else" should not be so hard!

    Any tips?
  • acrylian Administrator, Developer
    No, it has not changed and it will not as it will break lots of installations. The reason why the suffix is there is that Zenphoto uses the name to identify the image. you can have images with .gif., jpg or png (or possibly other suffixes) that besides that have all the same name within the same album.

    Using an id number is not possible therefore and would also neither really be seofriendly nor user friendly. I don't think that `.jpg.html` is really a SEO issue. You could probably write a rewrite rule to eliminate the image suffix but nevertheless Zenphoto will still generate these links. Unless you want to hack Zenphoto quite a lot. You can do that but we won't support it.
  • So I assume for the same reason there's no way to have the title or the id in place of the file name?

    Is there an easy shortcut to rename the image's filenames with the id?
  • There is a rename capability on the admin pages.
  • Yes I know but this way I have to do it manually, I was thinking something automatic when uploaded or when added to the db!

    Maybe I should start writing some plugin... as soon as I finish with the cart implementation ;)
  • There is an `seo cleanup` utility in the development branch that you could probably modify to do your task.

    Unfortunately, there is no ID until after the image has been instantiated, so no way to anticipate it for naming the file. Not sure why you don't just rename the files before upload to something you like.
  • Because there will be more than one person uploading and the only unique name would be the ID!!!
  • Well, then I guess you have a problem. Since if users can upload to the same folder they can create names that conflict.

    Guess you will have to make your own upload facility, then.

    BTW, You never initially mentioned that your real issue was that people could overwrite each other's files. It be more likely that someone can point you in the right direction if you actually tell them what your problem is.

    Users uploading and haveing conflicts seems to have nothing to do with if the link contains ".jpg" or not.
  • Wait, I managed already to have each user uploading in a different folder, but then if I copy the image to a folder where that name already exists I can have the problem if I don't change manually the name! That's why each image should have a unique name.. and the ID is the unique method, used in a lot of galleries with big numbers!!! Also from a client point of view having a unique ID is the only way to point a one file!!!

    I'm sorry I made confusion explaining that, and I did definitely went off topic here! But my points were related somehow :)
  • acrylian Administrator, Developer
    Well, it is simply not how Zenphoto is setup to work. We allow having same named images in different albums as Zenphoto is foremost file system based.

    It should be possible to write a tool (admin utility probably) that on request renames all images with their ID after they have been uploaded.
  • ok, thank you so much for the answer, I will go on the manual way... and yes I know how zenphoto is setup to work, and that's why people ask for shortcuts tips and tricks about features that are not natively supported!!!
  • acrylian Administrator, Developer
    Sure, that is why we answer as much as we can.
Sign In or Register to comment.