Jump to content

Recommended Posts

Now as you would know usually when you visit an image via URL you get like just the image, now I want to make it so when people either via google images etc. visit that images URL they not only get the image but a webpage with the image in it, any ideas??

 

seson greetings and thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/185748-images/
Share on other sites

yeah the images are like "image.jpg" and it display them but with their website around it, i stumbled on it while googling an image and clicked it and it came up with the page rather than the image and the page in a frame below, maybe someone here remembers the site name that does this

Link to comment
https://forums.phpfreaks.com/topic/185748-images/#findComment-980796
Share on other sites

I'm a bit rusty with .htaccess but try something like this:

 

RedirectMatch 301 (.*)\.(gif|jpg|jpeg|png)$ http://www.domain.com/redirect/$1.php

 

What this should do is redirect something like:

http://domain.com/images/picture1.gif

to

http://domain.com/redirect/picture1.php

 

Now, you really dont need to make a file for every pic. All you need to do is have a custom 404 error page in php that busts out the file name and if its a graphic displays it in an included fragment of HTML.

 

But like I said, I'm a bit rusty. Maybe someone more current could proof redirect.

 

 

HTH

Teamatomic

 

 

Link to comment
https://forums.phpfreaks.com/topic/185748-images/#findComment-980819
Share on other sites

You can use .htaccess and check for referrers. If the referrer is from Google images, then use mod_rewrite. You will need something in the image to identify it, like an ID in the image name. So you could have ID_randomString.jpg

So say  3222_8due938d.jpg, using mod_rewrite you can grab the 3222 with regex, then point that to a php file like  image.php?image_id=3222

 

Inside image.php you will have to 301 redirect them with ID to an album with the 3222 ID.

Link to comment
https://forums.phpfreaks.com/topic/185748-images/#findComment-980865
Share on other sites

if you have an image url:

 

http://site.com/img/pic.jpg

 

Just parse the url and curl the site

 

$img_url = "http://www.phpfreaks.com/media/images/forums/logo.png";

$url = parse_url($img_url);
$u = "http://".$url['host'];

$ch = curl_init($u);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$str = curl_exec($ch);
curl_close($ch); 

if ($str === false) {
echo "cURL failed  ";
die();
}

echo "<img src='{$img_url}'><hr>This image found here!<hr>";
echo $str;

 

Link to comment
https://forums.phpfreaks.com/topic/185748-images/#findComment-980867
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.