api - There is a way in Tumblr to get media images URL in the same domain of the blog name? -


lets blog http://foo.tumblr.com.

all post's images stored in xx.media.tumblr... (for example: https://24.media.tumblr.com/tumblr_kzjlfitnfe1qz4rgho1_250.jpg) (first 2 numbers can skipped)

but want url of image in same domain of blog, , looks this:

http://foo.tumblr.com/tumblr_kzjlfitnfe1qz4rgho1_250.jpg  

(that doesn't exist)

why need that? creating script, , generates canvas detects if image have transparency getimagedata (all .jpg skipped), since subdomain different, cross-domain security error, , canvas tainted, avoiding use of getimagedata.

so.. how can that?

i think tumblr api useful, how?

scrape sitemap posts , images. use api or javascript in browser console:

xmlin = prompt(); // view-source:biochemistri.es/sitemap1.xml parser = new domparser(); xmldoc=parser.parsefromstring(xmlin,"text/xml"); xmldoc.queryselectorall('loc')[0].remove(); posts = xmldoc.queryselectorall('loc'); postlist = []; (i=0;i<posts.length;i++) {postlist.push(posts[i].innerhtml)}; 

...to generate array containing posts, can navigated through photo posts (div.post.photo) , urls copied.

then generate new list of images loop , newimg = document.createelement('img'), setting origin attribute using newimg.setattribute('origin') = myphotolist[n] can used select image programmatically:

document.queryselector("img[origin='"+{photourl-highres}+"']" 

(or {photourl-1280}, {photourl-500}, {photourl-250} etc. once retrieved on xmlhttprequest, switch post in dom. {photourl-highres} in example above wouldn't work, it'd attribute page i'm indicating part you'd want theme html.

as explained in this post, there variable used more concise attribute full origin url if want bit more specific regular expressions.

this put of images onto local url, urls foo.tumblr.com/images/tumblr_kzjlfitnfe1qz4rgho1_250.jpg, , avoid cross-domain restrictions. i'm guessing it'd work if don't have ton of posts custom pages such you'd using store images have restriction on size (though suppose make second one).

also might sensible include css set display: none in case stumbles upon page accident, , redirect function homepage window.onload or similar.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -