Web Design Forums

Welcome! Please register or log in: Forgot your password? Why register?
You are here: Web Design Forums » Web Design Help » HTML and CSS Help » preventing right click also prevents hot linking? RSS

preventing right click also prevents hot linking?

This thread was started by ketanco and has been viewed 131 times, and contains 1 replies, with the last reply made by mlseim.
Post Reply
1
View ketanco's reputation
ketanco, Must... Post... More...! Private message   E-mail
Posted June 11 '09 at 06:31 PM
      Posts: 228
I know we really shouldnt prevent thr right clicking because it does not protect much, however, if we do that, does it automatically prevent hotlinking to our site or not? If not then I will have to go through all the steps to do that (prevent hotlinking), which I am trying to avoid for now....

Advertisement Register for free to hide these ads and participate in discussions!

2
1,251 points at 99% Moderator Repute
mlseim, WDF Moderator Private message  
Posted June 11 '09 at 06:47 PM
      Posts: 3,098
Hotlinking is a setting in either your webhost's control panel (for your site),
or you could possibly utilize .htaccess (search Google for examples).

You can also use PHP to render the image from a script,
where the end-user has no idea where it came from.

Like this ...
First, create a PHP script called "image.php" (see below).

<?php 
// path to your images (where they are stored). 
// include the trailing forward slash / 
$path="/photos/"

$filename=$path.$_GET['p']; 

// Get the dimensions 
list($width_orig$height_orig) = getimagesize($filename); 

// Resize if needed (in this example, full size ... no reduction). 
$width=$width_orig
$height=$height_orig

// Example of half-size reduction. 
//$width=$width_orig/2; 
//$height=$height_orig/2; 

// Resample 
$image_p imagecreatetruecolor($width$height); 
$image imagecreatefromjpeg($filename); 
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig); 

// Output 
header('Content-type: image/jpeg'); 
imagejpeg($image_pnull100); 

// Clean-up Memory 
imagedestroy($image_p); 
?>

Now use this on your HTML pages for each image ...

<img src="image.php?p=mypic.jpg">

The source of the image will be unknown, but the image will appear.
(this is for JPG or JPEG images only).
If it's zero degrees outside today, and it's supposed to be twice as cold tomorrow, how cold is it going to be?
mlseim is online now! Reply

Post Reply