Embedding Current Comic?

"Please leave a message at the beep, we will get back to you when your support contract expires."

Moderators: phlip, Prelates, Moderators General

Embedding Current Comic?

Postby clairm » Thu Oct 04, 2007 7:50 pm UTC

What a great site! Is there some snippet of HTML or other code I can use to embed whatever the current comic is on my home page?

Thanks,

Clair
clairm
 
Posts: 2
Joined: Thu Oct 04, 2007 7:46 pm UTC

Re: Embedding Current Comic?

Postby Hammer » Thu Oct 04, 2007 8:01 pm UTC

Each comic has something like this below it:

Image URL (for hotlinking/embedding): http://imgs.xkcd.com/comics/tapping.png
"What's wrong with you mathematicians? Cake is never a problem."
User avatar
Hammer
Because all of you look like nails.
 
Posts: 5491
Joined: Thu May 03, 2007 7:32 pm UTC

Re: Embedding Current Comic?

Postby clairm » Thu Oct 04, 2007 8:08 pm UTC

Understood, but I want the comic on my web site to change in sync with the one on xkcd, without changing code every couple days.
clairm
 
Posts: 2
Joined: Thu Oct 04, 2007 7:46 pm UTC

Re: Embedding Current Comic?

Postby crazyjimbo » Thu Oct 04, 2007 8:21 pm UTC

Maybe use a Google Gadget that already does what you want?
User avatar
crazyjimbo
 
Posts: 887
Joined: Fri Apr 20, 2007 11:45 pm UTC
Location: Durham, England

Re: Embedding Current Comic?

Postby johnw188 » Thu Oct 04, 2007 8:23 pm UTC

Learn some PHP ;)
johnw188
 
Posts: 26
Joined: Wed Feb 28, 2007 7:46 am UTC

Re: Embedding Current Comic?

Postby xooll » Fri Oct 05, 2007 3:03 am UTC

Sacrifice a goat to the interweb deities.
So, I got tired of the fact that the appearance of my band name in my signature made my posts on this forum the dominant result when googling for my music. Anyway, if you think I might happen to be a good musician, you can test this theory here.
User avatar
xooll
 
Posts: 804
Joined: Tue Oct 17, 2006 4:11 pm UTC

Re: Embedding Current Comic?

Postby TheTankengine » Fri Oct 05, 2007 4:31 am UTC

Please use the right forum.
be centered
be compassionate
be interesting
User avatar
TheTankengine
Our Fora-father
 
Posts: 3328
Joined: Tue Oct 17, 2006 2:09 pm UTC
Location: Louisville, KY

Re: Embedding Current Comic?

Postby abrenecki » Tue Oct 23, 2007 12:26 pm UTC

The xkcdgadget (deprecated) does exactly that, and has a static image that auto-updates. This static image also automatically resizes to a width of 320px.
In 30 seconds I have created a small app using the comic fetching 'library' I hacked together for xkcdmailer/xkcdgadget, which automatically issues a http location header to the current comic, as shown below. Come back to this thread tomorrow (or next update whenever that is) and the image will have changed.
Image
Here's the code, if the above worked:
Code: Select all
<img src='http://code.hoppingmouse.com/xkcdmailer/forward.php' alt='today\'s xkcd' />

Appreciated if you could put 'powered by xkcdmailer', and/or a link to http://ploogy.net/xkcdtools on there somewhere, but obviously this isn't mandatory.
One last thing: this script uses xkcdmailer's cache rather than checking on each request, so may lag by 15 minutes. The Google Gadget updates instantly.
(Edited links.)
(Edit: It appears I owe NFSN money. Will have paid tomorrow.)
(Edit: Added deprecated note)
Last edited by abrenecki on Wed Jan 14, 2009 12:23 pm UTC, edited 4 times in total.
User avatar
abrenecki
 
Posts: 62
Joined: Mon Sep 10, 2007 8:39 am UTC
Location: Mid North SA, Australia

Re: Embedding Current Comic?

Postby fatalfury » Sun Nov 11, 2007 7:00 am UTC

Thanks abrenecki! Your php image code works great. I use a custom start page, and I just decided to put together a custom comics page so I only have to check my local page to see all my comics. So thanks very much. :)
User avatar
fatalfury
 
Posts: 20
Joined: Tue Oct 09, 2007 6:25 pm UTC

Re: Embedding Current Comic?

Postby wkteoh » Wed Jan 14, 2009 10:01 am UTC

Sorry for reviving an old topic, but is there a way to embed it such that the mouse-over comments appear as well? Or does it already do that with the code?

WK
wkteoh
 
Posts: 1
Joined: Wed Jan 14, 2009 9:56 am UTC

Re: Embedding Current Comic?

Postby abrenecki » Wed Jan 14, 2009 12:21 pm UTC

Um... I can't think of a way to do it without calling a remote Javascript file. I could add the titletext to the bottom of the image, but this image is used as a source for the on-the-fly JPEG conversion xkcdmailer does for mobile users. Short answer: There's no way to do it without me writing more code. I'm working on Finch at the moment, but next time I decide to fiddle with xkcdmailer I might do something for you.
User avatar
abrenecki
 
Posts: 62
Joined: Mon Sep 10, 2007 8:39 am UTC
Location: Mid North SA, Australia

Re: Embedding Current Comic?

Postby Unparallelogram » Wed Jan 14, 2009 8:17 pm UTC

For your purposes, a page of iframes may be a better option.
Unparallelogram
 
Posts: 338
Joined: Mon Jul 28, 2008 4:16 am UTC


Return to The Help Desk

Who is online

Users browsing this forum: No registered users and 8 guests