How does giphy detect whether the image is embedded or not?

1

Giphy has a pretty neat trick with its gif images:

  • If they are embedded within another html page, as in, say

    <img src="https://media.giphy.com/media/DFqYLyMGpZ42c/giphy.gif" width="200">
    

    Then they will display properly as images:

  • On the other hand, if I just link, directly to the image, over at

    https://media.giphy.com/media/DFqYLyMGpZ42c/giphy.gif,

    then it serves a full html document, including links to the site and to more images from where the link came from:

I think this is a pretty legit thing to do, implemented cleanly with a minimum of fuss or aggravation to the user, and it is a brilliant business strategy, but the real question is: what kind of dark magic is this? What aspect of the html request tells giphy that it should serve an html document under the guise of a .gif image, without even a redirect or any change to the url?

E.P.

Posted 2017-07-13T13:35:03.057

Reputation: 159

1Probably checkign the HTTP_REFERER header to see if it was coming from their site or somewhere else... – ivanivan – 2017-07-13T13:39:50.613

No answers