Create an .htaccess file in your public_html directory with the following code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://(www.)?domain.com.*$ [NC]
RewriteRule .(gif|jpg)$ - [F]
Where domain.com is your domain.