Zubrag.com
January 21, 2018, 06:26:44 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Retreiving Thumb Images  (Read 29587 times)
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #14 on: February 05, 2007, 06:25:16 PM »

thus http:// must be added and not removed
Do you have thumbnails on the server stored with http:// prefix?

what would be the thumbnail file name for http://www.google.com?  Is it http://www.google.com.jpg or google.com.jpg

Logged
shaw
Newbie
*
Posts: 13


« Reply #15 on: February 06, 2007, 02:44:07 AM »

Files saved without http just google.com.jpg or www.zubrag.com.jpg etc.

If I could save them with 'http://', then of course I would, but...
you cannot save file that has \ / : * ? " < > and | in it
so I saved them without http://

We wouldn't talk about this subject if I could save them with http://.
and
I wouldn't need any script, because I would then call images
directly by using http://www.my-site.tld/thumbs/!!url!!

Again: !!url!! replaced by http://image-name.tld.jpg
And because !!url!! is treating google.com.jpg as a link, and because it configured
to add http:// to link automatically, you need to add http:// to google.com.jpg
Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #16 on: February 06, 2007, 06:10:01 AM »

Save following code as webthumb.php, and use it in your <img> tag.
Example: <img src="http://www.my-site.com/path/to/webthumb.php?url=http://www.google.com">
Assumed: www.google.com.jpg or google.com.jpg exists in the folder you specified as $thumbs_folder below

<?
// Usage: webthumb.php?url=http://website.com

// Path to the folder with thumbs. Note ending slash
$thumbs_folder = '/path/to/folder/with/thumbs/';

// Placeholder image name. Must be in the thumbs folder
$placeholder = 'placeholder.jpg';

///////////////// END OF SETTINGS /////////////////////

$fname = '';
if (isset($_REQUEST['url'])) {
  $fname = urldecode($_REQUEST['url']);
  // strip slashes if magic quotes enabled
  if (get_magic_quotes_gpc() == 1) {
    $fname = stripslashes($fname);
  }

  // strip http://
  $fname = str_replace('http://','',$fname);

  // remove all the slashes
  $fname = str_replace('/','',$fname);

  // add jpg at the end
  $fname = $fname . '.jpg';
}

header('Content-Type: image/jpeg');
if (file_exists($thumbs_folder.$fname)) {
  readfile($thumbs_folder.$fname);
}
elseif (file_exists($thumbs_folder.'www.'.$fname)) {
  readfile($thumbs_folder.'www.'.$fname);
}
else {
  readfile($thumbs_folder.$placeholder);
}
?>
Logged
shaw
Newbie
*
Posts: 13


« Reply #17 on: February 07, 2007, 03:26:25 AM »

This one is working like a charm.
Great job my friend, great job.

Thank you very much

Check this link www.amray.com
or better yet
http://www.amray.com/cgi/amray/dirs.cgi?lv=2&ct=Computers_,038_Internet-Software_,038_Programming
Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #18 on: February 07, 2007, 04:59:58 AM »

Glad it worked, and thank you very much for submission!

BTW, you could generate website images automatically (http://www.zubrag.com/scripts/website-thumbnail-generator.php) if you are on Windows hosting.
Logged
shaw
Newbie
*
Posts: 13


« Reply #19 on: February 07, 2007, 11:04:26 AM »

Oh well...
no M$ please Smiley

See this post
http://www.zubrag.com/forum/index.php?topic=82.0
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC