Are there best practices for adding watermarks to images based on the domain they are being displayed on in PHP?
When adding watermarks to images based on the domain they are being displayed on in PHP, you can use the `$_SERVER['HTTP_HOST']` variable to get the domain name and then apply different watermarks accordingly. One way to implement this is to create a function that takes the domain as a parameter and applies the appropriate watermark based on a conditional statement.
function addWatermarkBasedOnDomain($imagePath) {
$domain = $_SERVER['HTTP_HOST'];
if ($domain == 'example.com') {
// Add watermark for example.com
} elseif ($domain == 'anotherdomain.com') {
// Add watermark for anotherdomain.com
} else {
// Default watermark
}
// Add watermark to image at $imagePath
}
$imagePath = 'path/to/image.jpg';
addWatermarkBasedOnDomain($imagePath);