Welcome back and "Change the Forum Style?"

Want to just shoot the breeze? Forum 42 is the place!

Moderator: Moderators

benheck
Site Admin
Posts: 1887
Joined: Wed Dec 31, 1969 6:00 pm
Location: Wisconsin - Land of Beer and Cheese and Beer
Contact:

Post by benheck »

Cool, so that will cycle through any photos in that directory? Awesome, thanks!

Do they all have to be the same size?

-Ben
Image
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Post by gannon »

benheck wrote: Do they all have to be the same size?

-Ben
No, but if they aren't I recommend removing the height and width html attributes for the img tag since that will resize them to those dimensions.
benheck
Site Admin
Posts: 1887
Joined: Wed Dec 31, 1969 6:00 pm
Location: Wisconsin - Land of Beer and Cheese and Beer
Contact:

Post by benheck »

OK. Seems to work, but doesn't always return an image.

Ideas?

-Ben
Image
Skyone
Moderator
Posts: 6390
Joined: Tue Nov 29, 2005 8:35 pm
Location: it is a mystery
Contact:

Post by Skyone »

EnterTheHatrix, your logo is great, but the coloring scheme shouldn't be so teal for the body.

Iam, looks great, I think I'll make a theme for it if you're busy.

EDIT: Ben, does it return a 404 [X]? How many images do you have in the folder and how often does it NOT return one?
benheck
Site Admin
Posts: 1887
Joined: Wed Dec 31, 1969 6:00 pm
Location: Wisconsin - Land of Beer and Cheese and Beer
Contact:

Post by benheck »

It seems to only return one when you first goto the site or click MAIN.

-Ben

PS: I love my new site
Image
Skyone
Moderator
Posts: 6390
Joined: Tue Nov 29, 2005 8:35 pm
Location: it is a mystery
Contact:

Post by Skyone »

benheck wrote:It seems to only return one when you first goto the site or click MAIN.

-Ben

PS: I love my new site
You only put it in the source of the first page. Either you put the code gannon gave you into all of the pages or you can redesign the whole site to be php based.
benheck
Site Admin
Posts: 1887
Joined: Wed Dec 31, 1969 6:00 pm
Location: Wisconsin - Land of Beer and Cheese and Beer
Contact:

Post by benheck »

The whole site IS php based. The header.php file which the code is in gets called every time you do anything. I think. Wait... maybe it doesn't... Or does it?

-Ben
Image
Skyone
Moderator
Posts: 6390
Joined: Tue Nov 29, 2005 8:35 pm
Location: it is a mystery
Contact:

Post by Skyone »

benheck wrote:The header.php file which the code is in gets called every time you do anything. I think. Wait... maybe it doesn't... Or does it?
Hey, don't ask me. :P

Code: Select all

<?php
function is_image($image) {
  $t = preg_match('/\.png$|\.gif$|\.jpeg$|\.jpg$/i', $image);
  if ($t == true) return true;
  else return false;
}
$dir = 'http://benheck.com/images/rotate/';
$fp = opendir($dir);
while (($file = readdir($fp)) !== false) if (is_image($file)) $files[] = $file;
closedir($fp);
echo '<img border="0" src="'.$dir.$files[rand(0, count($files)-1)].'" width="207" height="60" />';
?> 
That should work, unless opendir cannot handle full links.
jeroen
Senior Member
Posts: 1573
Joined: Mon Oct 10, 2005 7:42 am
Location: The Netherlands

Post by jeroen »

ben the front page is screwed up.
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Post by gannon »

skyone: fairly sure it can't do that.
You might need to set the absolute path for the dir, in which case you'll have to use a different variable/string for the web root based path for the image.
benheck
Site Admin
Posts: 1887
Joined: Wed Dec 31, 1969 6:00 pm
Location: Wisconsin - Land of Beer and Cheese and Beer
Contact:

Post by benheck »

Yeah it's doing it because the subdirectories change when you navigate the site. Oh well, just have the pictures on the main page is fine.

Is there a way to swap it out, so if no picture is found it loads a default photo or ad?

-Ben
Image
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Post by gannon »

Sure, try

Code: Select all

<?php
function is_image($image) {
  $t = preg_match('/\.png$|\.gif$|\.jpeg$|\.jpg$/i', $image);
  if ($t == true) return true;
  else return false;
}
$dir = 'images/rotate/';
$fp = opendir($dir);
if ($fp === false) {
 echo '<img border="0" src="/images/default.jpg" />';
} else {
 while (($file = readdir($fp)) !== false) if (is_image($file)) $files[] = $file;
 closedir($fp);
 echo '<img border="0" src="/'.$dir.$files[rand(0, count($files)-1)].'" />';
}
?> 
Rekarp
Portablizer Extraordinaire
Posts: 2163
Joined: Thu Dec 28, 2006 1:52 am
PSN Username: Lnghrn_
Steam ID: rekarp
Location: Austin, Tx
Contact:

Post by Rekarp »

haha the pictures on the main page in the upper right corner are awsome lol. I am almost done with a NES wireframe just finishing the last touches after I eat dinner.
The wood master

Image

"I was under the impression Mac owners don't actually USE their machines, they just parade them around trying to evangelize the masses."
benheck
Site Admin
Posts: 1887
Joined: Wed Dec 31, 1969 6:00 pm
Location: Wisconsin - Land of Beer and Cheese and Beer
Contact:

Post by benheck »

Cool now it loads a pic for everything you do! Thanks Gannon you are the bomb!

Any other cool suggestions?

-Ben
Image
bicostp
Moderator
Posts: 10491
Joined: Mon Mar 07, 2005 5:47 pm
Steam ID: bicostp
Location: Spamalot
Contact:

Post by bicostp »

Just a minor glitch: When you click the "You can also check out: www.benheck.com" link on the book site, it loads the main page in the navigation tab area.

Ooh! Another random pic: take hat picture of Dale playing the Wii and scale/crop it down a bit. Add a speech bubble that just reads "$80!". Boom! Instant inside humor!
Last edited by bicostp on Fri Feb 02, 2007 6:25 pm, edited 2 times in total.
Post Reply