Gravatar返回错误的文件扩展名

时间:2017-01-02 21:08:46

标签: php gravatar

我试图通过在哈希末尾添加.jpg来从Gravatar获取JPG图像,如下所示: https://www.gravatar.com/avatar/00000000000000000000000000000000.jpg?d=wavatar&f=y

但是,如果我将它保存到磁盘:

file_put_contents($path, file_get_contents('https://www.gravatar.com/avatar/00000000000000000000000000000000.jpg?d=wavatar&f=y'));

或者如果我将它直接从浏览器保存到我的电脑,我注意到该文件实际上是PNG图像。

为什么?
我错过了什么吗?

THKS!

1 个答案:

答案 0 :(得分:1)

即使你最后有jpg,该链接也会给你png文件。如果你想要一个jpeg图像,请在你的php中试试。

echo '<img src="https://www.gravatar.com/avatar/'. md5(strtolower("myemail@gmail.com")).'"
class="img-circle" alt="User Image">';

代码phponline并下载this jpeg image