Zubrag.com
November 18, 2019, 09:43:03 PM *
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 36538 times)
shaw
Newbie
*
Posts: 13


« on: February 01, 2007, 02:38:06 AM »

Ok, I have generated URL images and saved them in directory
in domain.tld.jpg format. (I couldn' save with http:// of course)

If I call image using $url command, e.g. /thumbs/url=$url
I'm hitting brick wall because $url call it with http://
e.g. http://domain.tld.jpg and that is of course mismatch
and I'm getting nowhere.

So, what I'm asking, is there any way I can use thumb script to call
image but remove http:// somehow?

Any suggestions?

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 on: February 01, 2007, 06:14:19 AM »

Lets say you stored website images in the /home/public_html/url_images/

/home/public_html/url_images/website-image-1.jpg
/home/public_html/url_images/website-image-2.jpg
/home/public_html/url_images/website-image-3.jpg

And you have thumbnail generator in the /home/public_html/
So the path to it will be /home/public_html/thumb.php

Now when you are generating thumbnail you should provide relative path, based on the thumb.php path.
So thumb.php would treat that path as relative path from itself.

In our example html code for the image would be:
<img src="http://www.domain.tld/thumb.php?src=url_images/website-image-1.jpg&f=0">


Another example.
You have thumb.php in the same folder with images, i.e. if you have it like this:
/home/public_html/url_images/website-image-1.jpg
/home/public_html/url_images/website-image-2.jpg
/home/public_html/url_images/website-image-3.jpg
/home/public_html/url_images/thumb.php

In this case html code for the image would look like
<img src="http://www.domain.tld/url_images/thumb.php?src=website-image-1.jpg&f=0">
Logged
shaw
Newbie
*
Posts: 13


« Reply #2 on: February 01, 2007, 12:14:45 PM »

Remember old Alexa script the way it was setup. After snap is taken,
Alexa would save it as domain.tld and when called with
http://pthumbnails.alexa.com/image_server.cgi?&url=!!url!!
or $url or <%url%> etc. would place correspondenting URL thumb next to link.
(I wish I had that image_server.cgi script)

I am using script that uses !!url!! to call appropriate link from Index of links I have.
For example:
Link Title: !!link_url!! (replaced by title and link to that site))
Description: !!desc!! (replaced by link description)
Url: !!url!! (replaced by http://www.domain.tld)
And so on and that code will show 10 different links per page.

Now. I have Index of links and I have snapshots of all my links and I need
to place them next to my links.

What I am asking is, can your script do the following and to call snaps using !!url!! as in
<img src="http://www.domain.tld/url_images/thumb.php?src=!!url!!.jpg">
where !!url!! will be replaced with link url e.g. domain.tld and not with http://domain.tld
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #3 on: February 01, 2007, 01:50:05 PM »

In order to remove http:// from that string you have to add custom code to the script, lines 4 and 5 below:

if (isset($_REQUEST['src'])) {
  $from_name = urldecode($_REQUEST['src']);

  // replace http:// with empty space, i.e. just remove it
  $from_name = str_replace('http://','',$src);
}
Logged
shaw
Newbie
*
Posts: 13


« Reply #4 on: February 01, 2007, 11:53:26 PM »

Thanks Zugrag

Basically all I need is very simple, right to the point script.
Something like this:

<?

if (isset($_REQUEST['src'])) {
  $from_name = urldecode($_REQUEST['src']);

  // replace http:// with empty space, i.e. just remove it
  $from_name = str_replace('http://','',$src);
}

if {link.id}.jpg exist
display {link.id}.jpg
else
display placeholder.jpg

?>

but something short and sweet that will do the job.

You think you can come up with something?
Just strip down to the bone all options and make it
as simple as possible.

Thanks in advance

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #5 on: February 02, 2007, 04:44:39 AM »

So you need custom solution, like this

<?
// 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';

$fname = '';
if (isset($_REQUEST['url'])) {
  $fname = urldecode($_REQUEST['url']);

  // strip http://www.
  $fname = str_replace('http://www.','',$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);
}
else {
  readfile($thumbs_folder.$placeholder);
}
?>

Sample html code: <img src="webthumb.php?url=http://website.com">
Logged
shaw
Newbie
*
Posts: 13


« Reply #6 on: February 02, 2007, 12:13:35 PM »

Thank you for your very elegant solution

The good news, script add .jpg at the end, show placeholder.jpg image
and remove '/ ' after .tld
The bad news the rest wouldn’t work.

Lets try to make some sense in here.
Images saved either as domain.tld or as www.domain.tld
My program script set to replace !!url!! with http://www.domain.tld

Now, it looks like I’m trying to do that wrong way. I mean by that
instead of removing ‘http://’ we should add it to file name.

I came to this conclusion after I check thumb Properties.
This is what I found: webthumb.php?url=http://domain.tld
but url image was replaced by  placeholder.jpg instead.

I went to Address bar and tried (without any luck)
webthumb.php?url=http://domain.tld and then I tried
webthumb.php?url=domain.tld and I got the Image.

Are you with me so far? If yes, get yourself big cup of java
and lets add ‘http://’ to file name and hope it will work.

Thanks again for your input
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #7 on: February 02, 2007, 01:11:01 PM »

Maybe your server auto-escapes some characters.

Try replacing
  $fname = urldecode($_REQUEST['url']);

with
  $fname = stripslashes(urldecode($_REQUEST['url']));
Logged
shaw
Newbie
*
Posts: 13


« Reply #8 on: February 02, 2007, 02:04:58 PM »

Nope.  It still replaces !!url!! with 'http://domain.tld'

I'm thinking maybe something like:

if url = !!url!!
$fname = add http://$fname

maybe then http:// will echo with file name

What do you think?
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #9 on: February 02, 2007, 05:59:51 PM »

Well, its misunderstanding. Could you please post a detail example of what you have, how you run it,  and what you expect.

Like this:

1) I have website thumbnail stored in the /home/site/public_html/microsoft.com.jpg
2) Script saved as /home/site/public_html/thumbs.php
3) When i open it in browser like this: thumbs.php?url=http://www.microsoft.com I expect it to show image from step 1.

It would help me to understand what exactly is not working.
Logged
shaw
Newbie
*
Posts: 13


« Reply #10 on: February 02, 2007, 07:26:51 PM »

I have the following

1) I have web site thumbnail stored in the /home/sites/site2/web/thumbs
2) Script saved as /home/sites/site2/web/webthumb.php
3) I am using this string to open image in browser:
<a href="!!url!!" target="_blank"><img src="http://my-domain.com/webthumb.php?url=!!url!!" border="0"></a>
from inside of my main script.

Notice !!url!!, script replace it with link to site e.g. http://google.com or http://www.yahoo.com and so on.
I do not call them individually e.g. webthumb.php?url=http://google.com or webthumb.php?url=http://www.yahoo.com
script does it for me by replacing !!url!! with link to site

When I add links to index, they all saved with 'http'
So now I have, lets say 100 links, posted on 10 pages, 10 links per page
and my script display them all using variables from above in my second post.

Use this link and you will see what i want to achieve
http://www.alexa.com/search?q=zubrag
Check thumb Property
Logged
shaw
Newbie
*
Posts: 13


« Reply #11 on: February 04, 2007, 04:32:32 PM »

Maybe this will give you some idea how I want it to work

because !!url!! adding 'http://' to file name, then

$fname = 'http://'. $fname . '.jpg';

or something like that should solve this issue.

Or. instead of trying to remove 'http://' I think it should be added

or maybe [url] should be defined as
url = http://, $fname

Does it make any sense to you?
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #12 on: February 05, 2007, 11:40:51 AM »

So for example you have it like this:
<a href="http://www.google.com" target="_blank"><img src="http://my-domain.com/webthumb.php?url=http://www.google.com" border="0"></a>

The script i posted above will search for google.com.jpg in the /home/sites/site2/web/thumbs/   
I assume you already have website images stored in /home/sites/site2/web/thumbs/, so script will only try to find it and show in browser.

Is that correct or you expect script to do something else?
Logged
shaw
Newbie
*
Posts: 13


« Reply #13 on: February 05, 2007, 06:05:16 PM »

Template has it like this:
<a href="!!url!!" target="_blank"><img src="http://my-domain.com/webthumb.php?url=!!url!!" border="0"></a>
Please pay attention to !!url!! request

Final result come up like this:
<a href="http://www.google.com" target="_blank"><img src="http://my-domain.com/webthumb.php?url=http://www.google.com" border="0"></a>

The script i posted above will search for google.com.jpg in the /home/sites/site2/web/thumbs/
I assume you already have website images stored in /home/sites/site2/web/thumbs/, so script will only try to find it and show in browser.
Yep, it will find google.com.jpg www.zubrag.com.jpg etc. in thumb directory but...

remember !!url!!? It look for file http://google.com.jpg and not just google.com.jpg
thus http:// must be added and not removed
 
Logged
Pages: [1] 2
  Print  
 
Jump to:  

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