Suppose i have an image url :- example.com/myimg.png
I want to check whether it is included inside img src or someone directly opened it via browser.
What i need:- Check this image of GIPHY - https://media3.giphy.com/media/N8Lfh9gWcWYIU/giphy.gif
if you directly open it inside browser then it contains links at top and bottom of image but if you include this image inside img src then it only displays an image.
I tried below code but it is not a reliable solution:-
$ref = isset($_SERVER['HTTP_REFERER'])? $_SERVER['HTTP_REFERER']: "";
if ($ref != "")
{
header( 'Content-Type: image/jpeg' );
readfile( 'my-image.jpg' );
}
else
{
<img src="my-image.jpg">
<a href="#">My Link</a>
}