mirror of
https://github.com/kvazar-network/webapp.git
synced 2025-01-08 22:27:59 +00:00
add NS favicons
This commit is contained in:
parent
e48d60ac1d
commit
c04689a33d
@ -10,7 +10,7 @@ final class Icon {
|
||||
|
||||
private $_spriteZ = 800;
|
||||
|
||||
public function generateImageResource($hash, $width, $height, $filter = false) {
|
||||
public function generateImageResource($hash, $width, $height, $filter = false, $radius = 0) {
|
||||
|
||||
$this->_width = $width;
|
||||
$this->_height = $height;
|
||||
@ -74,12 +74,25 @@ final class Icon {
|
||||
|
||||
imagecopyresampled($resized, $identicon, 0, 0, (imagesx($identicon) - $this->_spriteZ * 3) / 2, (imagesx($identicon) - $this->_spriteZ * 3) / 2, $this->_width, $this->_height, $this->_spriteZ * 3, $this->_spriteZ * 3);
|
||||
|
||||
imagecolortransparent($resized, $bg);
|
||||
|
||||
if ($filter) {
|
||||
|
||||
imagefilter($resized, $filter);
|
||||
}
|
||||
|
||||
if ($radius) {
|
||||
|
||||
imagearc($resized, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $bg);
|
||||
imagefilltoborder($resized, 0, 0, $bg, $bg);
|
||||
imagearc($resized, $width-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $bg);
|
||||
imagefilltoborder($resized, $width-1, 0, $bg, $bg);
|
||||
imagearc($resized, $radius-1, $height-$radius, $radius*2, $radius*2, 90, 180, $bg);
|
||||
imagefilltoborder($resized, 0, $height-1, $bg, $bg);
|
||||
imagearc($resized, $width-$radius, $height-$radius, $radius*2, $radius*2, 0, 90, $bg);
|
||||
imagefilltoborder($resized, $width-1, $height-1, $bg, $bg);
|
||||
|
||||
imagecolortransparent($resized, $bg);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
imagepng($resized);
|
||||
imagedestroy($resized);
|
||||
|
@ -5,17 +5,24 @@ require_once('../library/icon.php');
|
||||
|
||||
if (isset($_GET['hash'])) {
|
||||
|
||||
$hash = md5($_GET['hash']);
|
||||
|
||||
$width = isset($_GET['width']) ? (int) $_GET['width'] : 60;
|
||||
$height = isset($_GET['height']) ? (int) $_GET['height'] : 60;
|
||||
|
||||
$radius = isset($_GET['radius']) ? (int) $_GET['radius'] : 0;
|
||||
|
||||
header("Content-Type: image/png");
|
||||
|
||||
if (CACHE_ENABLED) {
|
||||
|
||||
$filename = dirname(__FILE__) . '/../cache/' . $_GET['hash'] . '.png';
|
||||
$filename = dirname(__FILE__) . '/../cache/' . $hash . '.png';
|
||||
|
||||
if (!file_exists($filename)) {
|
||||
|
||||
$icon = new Icon();
|
||||
|
||||
file_put_contents($filename, $icon->generateImageResource(md5($_GET['hash']), 60, 60, false));
|
||||
file_put_contents($filename, $icon->generateImageResource($hash, $width, $height, false, $radius));
|
||||
}
|
||||
|
||||
echo file_get_contents($filename);
|
||||
@ -24,6 +31,6 @@ if (isset($_GET['hash'])) {
|
||||
|
||||
$icon = new Icon();
|
||||
|
||||
echo $icon->generateImageResource(md5($_GET['hash']), 60, 60, false);
|
||||
echo $icon->generateImageResource($hash, $width, $height, false, $radius);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
<meta name="description" content="Open Source Content Exploring Platform for Kevacoin Blockchain" />
|
||||
<base href="<?php echo BASE_URL; ?>" />
|
||||
<?php if ($ns) { ?>
|
||||
<link rel="icon" type="image/png" href="image.php?hash=<?php echo $ns; ?>&width=32&height=32&radius=16" />
|
||||
<?php if ($page) { ?>
|
||||
<title><?php echo $namespaceValue ? $namespaceValue : $ns; ?> | PART <?php echo $page; ?> | KVAZAR</title>
|
||||
<meta name="robots" content="noindex,follow" />
|
||||
|
Loading…
Reference in New Issue
Block a user