I've been putting it off all week, but this morning I finally dove in and made changes to the picture uploading system. I'm 90% done, and it has gone fairly well so far.
Don't panic too much, all photos still exist in their old location, and I'm leaving the /getpic/ scripts in place for the foreseeable future. So everything will continue to work as it always has.
But I'm bringing the new system up in parallel, so the new way will start to work alongside the old way, and maybe eventually we'll get rid of the old way (but we'll always leave /getpic/ in place so no external links will ever break.)
The goal here is to get PHP completely out of the equation when an HTTP request is for an image file.
There is a new directory /library. Inside /library are folders for each user id (well, for each user id that has uploaded pictures.) A copy of every picture you have uploaded is now inside that directory. In the old folder (kept outside the webserver domain) the files had unique numeric filenames corresponding to the id for that picture in the database. All file information (name,date,user,etc...) was in the database. In the new system the info is still in the database, but the filename is kept the same as when you uploaded it (except in the case of duplicates where the system appends _1, _2, _3 as necessary, as well as replacing spaces with underscores.)
So where img src="/getpic/123" would request picture 123 (which had, say, the real filename 'test.jpg' when uploaded,) the new tag would be img src="/library/5/test.jpg".
The /5/ in the above example is my user id number.
The thumbnail is still at img src="/getthumb/123", but now it is also at img src="/library/5/thumbnail/test.jpg".
But remember /getpic/123 will continue to work, so nothing is going to break. When you upload new pictures they go to both the old directory and the new directory (same for thumbnails.)
Next I am going to update the post script to do some substitution. I am thinking of using this shorthand for inserting pictures: <[xxx]> where xxx is either the picture number or the exact text of the description you gave the picture when uploading. When you post an entry with that code in it, the post script will replace it with the appropriate img src="/library/n/xxx" format.
If that seems to work I'll write something to go back through the database and change all the /getpic/ statements to the new form.
This will be much more efficient. And it also will solve the weird problems we sometimes encounter because the file extension is not visible in the html. Some browsers get confused and download the file to disk rather than displaying it in the browsers. This will become even more of a problem as we move to dealing with many more mime types (moving images and such.)
This is a test
Holy cow, it works!
You can now post images with the new notation:
<[xxx]>
where xxx is either the id number you get when you upload the picture, or the exact text of the description you gave the picture. If you have duplicate description text you might not get the picture you want (although it will always take a picture of yours over a picture of someone else's which has the same description.) The id number will always be unique.
And if you don't like the way the system makes the tags (with border=0 and alt= the description you gave the upload) you can still make the tag manually:
<img src="/library/n/filename.ext">
where n is your user id number (which you can find on [settings]) and filename.ext is the filename (with extension) as you uploaded it.
All of these options are spelled out (for copy & pasting) from the upload page.
test--yep, it works. I used the text [Gnome 2] and the system generated the tag < img src="/library/12/gnomes3.gif" border="0" alt="Gnome 2" >. It took a couple of tries to get back into this comment via [edit], I noticed.
I was just screwing with the edit script so you probably hit it while it was in mid upload. I'm pretty sure edit is working okay, but I always appreciate any testing anyone wants to do.
Hopefully you used <[Gnome 2]> to get the result, no?
Yep--here's one I just uploaded, using the text and the number . Anyone recognize this?
maxell?
Nope, but good guess. I'll keep the quiz open until midnight. ..hey, tomorrow's a leap day!
cd-r ?
Suntan coupon?
that sounds more like it jim
So really, if you wanted to play around with the image (change border, add space around it) you could use [xxx], then just hit edit after you posted and make all the changes to the newly-generated tag in the post. What about people getting posts by email? (Not sure what they see, image-info wise, as it stands, or if it matters.)
Yeah, I hadn't thought of that, but if you wanted to change the border or something, your idea would be the easiest way to go.
Right now all HTML tags (including image tags) are stripped from the post before it is sent in email. It's just a religious conviction of mine that email should be plaintext. Probably there should at least be a some sort of textual clue that you are missing an image in these cases.
"An example is here [dumb picture]..."
Tick...tick...tick *buzzer*
This probably wasn't a fair contest. If you use amazon 1-clickTM shopping, you see this .gif telling you you have 90 more minutes to keep shopping before your order is finalized. But excellent guesses all around.
I made some more tweaks this morning. The script was allowing for the possibility of uploading a duplicate filename which would overwrite the old one. I've put in some checks so now a duplicate filename will get _1 (or _2 or _3) appended to the end of the file (so test.jpg becomes test_1.jpg)
hm. it's not working for me. I get the little 'there's supposed to be an image" here icon when I make a post (using any of the code options), although the image uploads fine. Also on the post bill just made, I can't see his image. is it just me?
Okay, I'm looking into this...
Yes, I broke this pretty badly earlier today as I was fixing the possible same filename problem.
Thanks for the reports. I know it's a pain when it doesn't work.
It seems to be working correctly now. Please let me know. Sorry that you might have to upload some stuff over again (if you were uploading today.)
Better controls (like 'delete photo') are on the way for managing your collections.
no worries - love the process. thanks jim.
|
Don't panic too much, all photos still exist in their old location, and I'm leaving the /getpic/ scripts in place for the foreseeable future. So everything will continue to work as it always has.
But I'm bringing the new system up in parallel, so the new way will start to work alongside the old way, and maybe eventually we'll get rid of the old way (but we'll always leave /getpic/ in place so no external links will ever break.)
The goal here is to get PHP completely out of the equation when an HTTP request is for an image file.
There is a new directory /library. Inside /library are folders for each user id (well, for each user id that has uploaded pictures.) A copy of every picture you have uploaded is now inside that directory. In the old folder (kept outside the webserver domain) the files had unique numeric filenames corresponding to the id for that picture in the database. All file information (name,date,user,etc...) was in the database. In the new system the info is still in the database, but the filename is kept the same as when you uploaded it (except in the case of duplicates where the system appends _1, _2, _3 as necessary, as well as replacing spaces with underscores.)
So where img src="/getpic/123" would request picture 123 (which had, say, the real filename 'test.jpg' when uploaded,) the new tag would be img src="/library/5/test.jpg".
The /5/ in the above example is my user id number.
The thumbnail is still at img src="/getthumb/123", but now it is also at img src="/library/5/thumbnail/test.jpg".
But remember /getpic/123 will continue to work, so nothing is going to break. When you upload new pictures they go to both the old directory and the new directory (same for thumbnails.)
Next I am going to update the post script to do some substitution. I am thinking of using this shorthand for inserting pictures: <[xxx]> where xxx is either the picture number or the exact text of the description you gave the picture when uploading. When you post an entry with that code in it, the post script will replace it with the appropriate img src="/library/n/xxx" format.
If that seems to work I'll write something to go back through the database and change all the /getpic/ statements to the new form.
This will be much more efficient. And it also will solve the weird problems we sometimes encounter because the file extension is not visible in the html. Some browsers get confused and download the file to disk rather than displaying it in the browsers. This will become even more of a problem as we move to dealing with many more mime types (moving images and such.)
- jim 2-28-2004 9:31 pm
This is a test
- jim 2-28-2004 10:59 pm [add a comment]
Holy cow, it works!
You can now post images with the new notation:
<[xxx]>
where xxx is either the id number you get when you upload the picture, or the exact text of the description you gave the picture. If you have duplicate description text you might not get the picture you want (although it will always take a picture of yours over a picture of someone else's which has the same description.) The id number will always be unique.
And if you don't like the way the system makes the tags (with border=0 and alt= the description you gave the upload) you can still make the tag manually:
<img src="/library/n/filename.ext">
where n is your user id number (which you can find on [settings]) and filename.ext is the filename (with extension) as you uploaded it.
All of these options are spelled out (for copy & pasting) from the upload page.
- jim 2-28-2004 11:03 pm [add a comment]
test--yep, it works.
I used the text [Gnome 2] and the system generated the tag < img src="/library/12/gnomes3.gif" border="0" alt="Gnome 2" >. It took a couple of tries to get back into this comment via [edit], I noticed.
- tom moody 2-28-2004 11:14 pm [add a comment]
I was just screwing with the edit script so you probably hit it while it was in mid upload. I'm pretty sure edit is working okay, but I always appreciate any testing anyone wants to do.
Hopefully you used <[Gnome 2]> to get the result, no?
- jim 2-28-2004 11:22 pm [add a comment]
Yep--here's one I just uploaded, using the text
and the number
. Anyone recognize this?
- tom moody 2-28-2004 11:26 pm [add a comment]
maxell?
- dave 2-29-2004 12:34 am [add a comment]
Nope, but good guess. I'll keep the quiz open until midnight. ..hey, tomorrow's a leap day!
- tom moody 2-29-2004 12:51 am [add a comment]
cd-r ?
- bill 2-29-2004 2:31 am [add a comment]
Suntan coupon?
- jim 2-29-2004 2:37 am [add a comment]
that sounds more like it jim
- bill 2-29-2004 2:48 am [add a comment]
So really, if you wanted to play around with the image (change border, add space around it) you could use [xxx], then just hit edit after you posted and make all the changes to the newly-generated tag in the post. What about people getting posts by email? (Not sure what they see, image-info wise, as it stands, or if it matters.)
- tom moody 2-28-2004 11:30 pm [add a comment]
Yeah, I hadn't thought of that, but if you wanted to change the border or something, your idea would be the easiest way to go.
Right now all HTML tags (including image tags) are stripped from the post before it is sent in email. It's just a religious conviction of mine that email should be plaintext. Probably there should at least be a some sort of textual clue that you are missing an image in these cases.
- jim 2-28-2004 11:46 pm [add a comment]
"An example is here [dumb picture]..."
- tom moody 2-29-2004 12:51 am [add a comment]
Tick...tick...tick *buzzer*
This probably wasn't a fair contest. If you use amazon 1-clickTM shopping, you see this .gif telling you you have 90 more minutes to keep shopping before your order is finalized.
But excellent guesses all around.
- tom moody 2-29-2004 8:01 am [add a comment]
I made some more tweaks this morning. The script was allowing for the possibility of uploading a duplicate filename which would overwrite the old one. I've put in some checks so now a duplicate filename will get _1 (or _2 or _3) appended to the end of the file (so test.jpg becomes test_1.jpg)
- jim 2-29-2004 7:40 pm [add a comment]
hm. it's not working for me. I get the little 'there's supposed to be an image" here icon when I make a post (using any of the code options), although the image uploads fine. Also on the post bill just made, I can't see his image. is it just me?
- sally mckay 2-29-2004 11:30 pm [add a comment]
Okay, I'm looking into this...
- jim 2-29-2004 11:48 pm [add a comment]
Yes, I broke this pretty badly earlier today as I was fixing the possible same filename problem.
Thanks for the reports. I know it's a pain when it doesn't work.
It seems to be working correctly now. Please let me know. Sorry that you might have to upload some stuff over again (if you were uploading today.)
Better controls (like 'delete photo') are on the way for managing your collections.
- jim 3-01-2004 12:03 am [add a comment]
no worries - love the process. thanks jim.
- sally mckay 3-01-2004 12:12 am [add a comment]