在友情链接前面加一个显示ico图标的小功能,需要服务器可以访问google。
因为这个方法会实时去访问谷歌接口,会比较慢,然后我为了加载速度就放弃了。另外国内也有提供这个api的,可以去搜索一下。
使用效果如下图:

前端调用代码:
<img src="https://bbs.ss/ico.php?url=<?php echo $v['link']?>" style="width:18px;height:18px;margin:4px 0 5px 0;" class="img-fluid rounded-circle avatar-3">
ico.php的代码如下:
<?php
if (isset($_GET['url'])) {$icon = file_get_contents("http://www.google.com/s2/favicons?sz=64&domain=" . $_GET['url']);
if ($icon) {header('Content-type:image/png');
echo $icon;
}else{
header('Content-type:image/png');
echo file_get_contents('https://bbs.ss/favicon.ico');
}
}