In ACP -> Attachments settings you can enable secure download.
Then when an image is hotlinked, nothing will show up. Just a broken image icon.
If its a file and the link is clicked, users will go to your site and see a page with this text: You are not authorised to view, download or link from/to this site.
I like to display an image that replaces the image users try to hotlink:

If secure downloads is enabled, you can achieve this by a single core edit.
Open download/file.php
Find:
Code: Select all
else if (!download_allowed())
{
send_status_line(403, 'Forbidden');
trigger_error($user->lang['LINKAGE_FORBIDDEN']);
}
Code: Select all
else if (!download_allowed())
{
// Send “403 Forbidden” status so browsers know it's a valid image response
send_status_line(403, 'Forbidden');
// Serve the warning image instead of the broken icon
header('Content-Type: image/jpg');
header('Cache-Control: public, max-age=86400'); // cache for 1 day
readfile($phpbb_root_path . 'images/stop.jpg');
exit;
}
Now your stop.jpg will display when images are hotlinked from a non whitelisted domain.
Hotlinked files will redirect to the stop.jpg on your site