Bloqueia o uso de suas imagens em outros sites via .htaccess ou funções WordPress.
/**
* Via wp_headers (PHP)
*/
add_filter('wp_headers', function (array $headers): array {
if (is_attachment() || (isset($_SERVER['REQUEST_URI']) && preg_match('/.(jpg|jpeg|png|gif|webp|svg)$/i', $_SERVER['REQUEST_URI']))) {
$referer = $_SERVER['HTTP_REFERER'] ?? '';
$meu_host = parse_url(home_url(), PHP_URL_HOST);
if ($referer && !str_contains($referer, $meu_host)) {
status_header(403);
exit;
}
}
return $headers;
});
/*
* Ou via .htaccess:
*
* RewriteEngine on
* RewriteCond %{HTTP_REFERER} !^$
* RewriteCond %{HTTP_REFERER} !^https://(www.)?meusite.com.br/ [NC]
* RewriteRule .(jpg|jpeg|png|gif|webp|svg)$ - [NC,F,L]
*/