Integrate third-party images in a privacy-compliant manner

Integrate third-party images in a privacy-compliant manner

Some of you may be facing the problem of having to embed images (which change from time to time) from a foreign domain (e.g. a cachet) on your website. Here the problem lies in the foreign domain of the corresponding provider, i.e. you would have to transfer the graphic to your server first and only then deliver it to your own visitors.

This is fortunately not a problem with php:

<?php
$contents = file_get_contents('http://www.example.com/sehrsehrgeilesbild.png');
header('Content-Type: image/png');
echo $contents;
?>

The sample code loads the image (PNG) from the foreign server and then plays it back. The URL of the PHP script can then simply be pasted like an image.

If you have many thousands of visitors I recommend you to cache the image and update the content with a cronjob daily.

Note: This text is copyrighted

Please send coffee donations to: 0xd0803A568615A18403C3722AC6dBb3202FD14034 (Ethereum)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code