By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

Image rotation

P: n/a
Jez
I'm looking at using random image rotation on one of my sites and have
found the following script very helpful:

http://www.alistapart.com/d/randomizer/rotate.txt

Everything works, but once you've randomly chosen the file on the
server wouldn't it be simpler/quicker to say ...

if ($img!=null) {
header("Location: ".$img."");
}

instead of ...

if ($img!=null) {
$ext = strrchr($img,'.');
if ($ext==".jpg") $ext = ".jpeg";
$contentType = 'Content-type: image/' . substr( $ext, 1,
(strlen($ext)) );
header ($contentType);
readfile($img);
}

I'm no expert, but this seems to work for me.

Please let me know if I've got this all wrong?

Thanks!

Jez
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Jez" a écrit le 19/11/2003 :
I'm looking at using random image rotation on one of my sites and have
found the following script very helpful:

http://www.alistapart.com/d/randomizer/rotate.txt

Everything works, but once you've randomly chosen the file on the
server wouldn't it be simpler/quicker to say ...

if ($img!=null) {
header("Location: ".$img."");
}

instead of ...

if ($img!=null) {
$ext = strrchr($img,'.');
if ($ext==".jpg") $ext = ".jpeg";
$contentType = 'Content-type: image/' . substr( $ext, 1,
(strlen($ext)) );
header ($contentType);
readfile($img);
}

I'm no expert, but this seems to work for me.

Please let me know if I've got this all wrong?


Because the first one force the Web Client to show only the image
whereas the second could be used in a HTML page in a <img> tag.
Assuming you php page is rotate.php with the second you could use in
any HTML page :
<img src="rotate.php" alt="My rotated image">
You simply can't whith your method.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.