iOS: How can I display a photo from my phone in a HTML IMG tag?

178 views
Skip to first unread message

Kurt

unread,
Feb 22, 2013, 1:48:32 PM2/22/13
to phon...@googlegroups.com
So I am using the native iOS api to get a list of photos and need to display both the thumbnails and the photo in a HTML page.

The photo (ALAsset) has a url like this:  assets-library://asset/asset.JPG?id=DFB2A27D-C1D3-4E5B-8E2A-3ADD7AA9E317&ext=JPG

So I tried the following in my HTML:

<img src="assets-library://asset/asset.JPG?id=DFB2A27D-C1D3-4E5B-8E2A-3ADD7AA9E317&ext=JPG />

But this does not work (broken img link).  Anyone know how to show an img from the AssetLibrary?

Thanks in advance.
Kurt

mr.s

unread,
Feb 22, 2013, 2:03:05 PM2/22/13
to phon...@googlegroups.com
Return the base64-encoded data from the fileobject and put that directly into the SRC attribute.

Kurt

unread,
Feb 22, 2013, 2:15:42 PM2/22/13
to phon...@googlegroups.com
Thanks for your response.

And how about the thumbnail?
It looks like there is an api to get the thumbnail from the Asset as a CGImageRef.  How would I show the thumbnail in HTML?

Thanks!

Brian

unread,
Jun 17, 2013, 4:24:49 PM6/17/13
to phon...@googlegroups.com
Kurt, did you ever get this working?  I'd like to use the path to the photo library in the img src, but I can't find a way to make that work.

Thabo Letsoalo

unread,
Jun 19, 2013, 5:12:01 AM6/19/13
to phon...@googlegroups.com
Brian, I don't think iOS allows that (I stand to be corrected). In Android you can set the src to file:///, but I think in iOS you might have to do what mr.s suggested (return a base 64 string from the file object - take a look at the file api in phonegap documentation).

Giacomo Balli

unread,
Jun 19, 2013, 8:43:03 AM6/19/13
to phon...@googlegroups.com
since you're already retrieving the original, just resize and create a thumbnail on the fly.

Thabo Letsoalo

unread,
Jun 19, 2013, 9:52:46 AM6/19/13
to phon...@googlegroups.com
Hi, the following link shows how to use the HTML5 file api to select pictures, preview them and then upload them:


--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/JtD75u_d6XQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages