Changing the template
sferrier
Registered Users Posts: 2 Beginner grinner
Good afternoon, all.
I'm working on a piece of PHP code that will allow me to embed random (smugmug-hosted) thumbnail images in my own website. So far it's working great, except for one thing - template selection. The code works great as long as the selected template is one that includes thumbnail-sized images - but if I were to change it to one that does not, then the thumbnails are no longer available to me.
Was hoping that someone might be able to give me some advice on how to change the template?
Thanks so much,
Shawn.
p.s. I've included my code below for your perusual - but please be kind and a little understanding - this is my first piece of PHP code!
[php]
//srand((float) microtime() * 10000000);
$galleries = array("Van Halen 2004 San Jose FRONT ROW!" => "http://onethumb.smugmug.com/gallery/189557",
"All the rest...." => "http://onethumb.smugmug.com/gallery/78324");
$imagedir = "/photos/";
$rand = array_rand($galleries);
$url = $galleries[$rand];
$urlparts = parse_url($url);
$html = file_get_contents($url);
$regexptrn = "|[.\s]*?([img]\"http://{$urlparts}{$imagedir}.*?\-ti\.jpg\".*?[/img])|i";
preg_match_all($regexptrn, $html, $imgs);
if (count($imgs[0]) < 1) {
echo "No images found.";
exit;
}
$rand = array_rand($imgs[2]);
echo "{$imgs[2][$rand]}";
?>
[/php]
I'm working on a piece of PHP code that will allow me to embed random (smugmug-hosted) thumbnail images in my own website. So far it's working great, except for one thing - template selection. The code works great as long as the selected template is one that includes thumbnail-sized images - but if I were to change it to one that does not, then the thumbnails are no longer available to me.
Was hoping that someone might be able to give me some advice on how to change the template?
Thanks so much,
Shawn.
p.s. I've included my code below for your perusual - but please be kind and a little understanding - this is my first piece of PHP code!
[php]
//srand((float) microtime() * 10000000);
$galleries = array("Van Halen 2004 San Jose FRONT ROW!" => "http://onethumb.smugmug.com/gallery/189557",
"All the rest...." => "http://onethumb.smugmug.com/gallery/78324");
$imagedir = "/photos/";
$rand = array_rand($galleries);
$url = $galleries[$rand];
$urlparts = parse_url($url);
$html = file_get_contents($url);
$regexptrn = "|[.\s]*?([img]\"http://{$urlparts}{$imagedir}.*?\-ti\.jpg\".*?[/img])|i";
preg_match_all($regexptrn, $html, $imgs);
if (count($imgs[0]) < 1) {
echo "No images found.";
exit;
}
$rand = array_rand($imgs[2]);
echo "{$imgs[2][$rand]}";
?>
[/php]
0