Skip Navigation

A technical challenge! - placeholding email submitted pics

Travel Forums System Talk A technical challenge! - placeholding email submitted pics

1. Posted by Dodgey (Respected Member, 6 posts) 4 Nov '08 07:18

I mentioned this in another thread as a sub-topic but I think it deserves a post of it's own.

The facility to email in blogs is awesome. But I would not want all my pics at the bottom of a post - I make quite lengthy posts at times.

How much of a headache would it be to code it so, for example, if you put "xxxsunsetincairo.jpgxxx" in the text of the email, and made sure you attached a picture called "sunsetincairo.jpg" to then have it put the picture in the "xxx" placeholder location? Would be great.

Currently, when I'm without the web for a long period of time I compose my blog in Word, leaving double line breaks between paragraphs (as one line break gets stripped for some reason), then I put in the text somthing like, "Insert pic: Sunset in cairo". I log on, update my map, upload my pics, then paste my Word text into the blog, then systematically replace the "insert Pic:" bits with the actual pictures.

Would be grand if all I had to do was email, then at a later date when I had time, index the pictures properly.

2. Posted by Sam I Am (Admin, 5572 posts) 5 Nov '08 00:59

Agreed this would be nice, but unfortunately here we're also somewhat at the mercy of the medium submitting the text and photos, which could either be an email or an MMS. The main downside is that there are literally dozens of possible email providers. Each send emails in a slightly different way, and when it comes to attached images they are also handled differently. I tried something yesterday which I thought might work, but unfortunately, the filenames are changed when uploading from email. Otherwise it is already fully possible to just include the text code in the email where you want the photos and if the photo is already uploaded it will properly insert them there. So basically you can already send an email saying something like:

--
text yadayadayada

[img=http://photos.travellerspoint.com/4/DSC03009.jpg]

more text

[img=http://photos.travellerspoint.com/4/DSC03009.jpg]

more text and thank you for reading my blog
---

The above would insert photos in both those places, with text around it.

The only downside is that if you then attach the images to that email to upload them automatically, their filenames are actually changed while uploading, so you won't know the exact link (besides the fact that they would also show twice in the blog entry of course).

So, one way around that would be to first upload all the photos (to any site, doesn't actually have to be Travellerspoint). Then insert the link to each photo as per above with the correct url for each photo.

Hit send on your email and it should work!!

[ Edit: Edited on Nov 5, 2008, at 12:59 AM by Sam I Am ]

3. Posted by Peter (Admin, 5355 posts) 5 Nov '08 04:55

Quoting Sam I Am

I tried something yesterday which I thought might work, but unfortunately, the filenames are changed when uploading from email.

Is that because the filename was over a certain length? Or because it was the same as an already uploaded file? Or does it automatically change the name of every moblogged photo? I could check myself, but just thought I'd ask ;)

I know filenames can be changed by us if they are long or duplicates of existing ones, but didn't know if they'd also change jsut because they're moblogged. Otherwise, you *could* ensure you kept the filename short and then you can guess where the image is going to end up.

4. Posted by Sam I Am (Admin, 5572 posts) 5 Nov '08 05:12

Quoting Peter

Quoting Sam I Am

I tried something yesterday which I thought might work, but unfortunately, the filenames are changed when uploading from email.

Is that because the filename was over a certain length? Or because it was the same as an already uploaded file? Or does it automatically change the name of every moblogged photo? I could check myself, but just thought I'd ask ;)

I know filenames can be changed by us if they are long or duplicates of existing ones, but didn't know if they'd also change jsut because they're moblogged. Otherwise, you *could* ensure you kept the filename short and then you can guess where the image is going to end up.

The ones I tried were short. And I'm pretty sure I hadn't uploaded the images before, but maybe they were dupes... actually, looking at the code it looks like the system assigns a guaranteed unique filename by doing some extra additions before the filename. I'm not sure why/if it's necessary though?

5. Posted by Sander (Moderator, 4275 posts) 5 Nov '08 08:29

You could implement this pretty easily, actually, just by having some dedicated code which'll be dynamically replaced by the images (in the order of attachment).

Right now the moblog check goes through all attachments, saves the images, and appends them to the text which will later be turned into the blog entry. Rather than immediately appending, you could parse the text and do a string replace on, say, all text which exactly matches "[img=placeholder]", replacing that with the next image in the list. Once that's done, delete any remaining "[img=placeholder]" strings (to prevent 'broken images'), and append any remaining images to the text.
Then send the text off to become a blog entry, same as now.


The unique filename protection for moblogged photos is necessary, as the coldfusion attribute which we usually use for this doesn't work on files which already exist, rather than come from a file upload control, and otherwise we'd overwrite existing files in the case of name clashes.

[ Edit: Edited on Nov 5, 2008, at 8:39 AM by Sander ]

6. Posted by Sam I Am (Admin, 5572 posts) 8 Nov '08 07:16

Thanks for the idea Sander. Dodgey, here you go!! Seems to work pretty smoothly :)

7. Posted by Dodgey (Respected Member, 6 posts) 8 Nov '08 08:04

Wow! Sweet - thanks for that! - It makes the moblogging really a useful tool. Just landed in Cape Town, off into Namibia, Botswana and Zimbabwe in 48 hours and this will make "pre-blogging" a doddle.

Nice work and many thanks!

8. Posted by Gelli (Travel Guru, 2457 posts) 9 Nov '08 07:05

Damned. That IS good.

You really do like making it harder for me to have an excuse for not blogging often enough, don't you?

  • sigh*. Suppose i better catch up as quickly as possible so i can then start sending emailed updates