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, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
header('Content-type: image/jpeg');
imagejpeg($image_p, null, 100);
// 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).