SPR-787 use same logo resized
This commit is contained in:
parent
2387fd467e
commit
06cdf1484d
3 changed files with 107 additions and 20 deletions
40
Template.php
40
Template.php
|
@ -30,7 +30,6 @@ class Template {
|
|||
return $instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template constructor.
|
||||
*/
|
||||
|
@ -80,4 +79,43 @@ class Template {
|
|||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an image tag and includes the first found image correctly resized
|
||||
*
|
||||
* @param string $tag
|
||||
* @param array $attributes
|
||||
* @param int $w
|
||||
* @param int $h
|
||||
* @return string
|
||||
*/
|
||||
public static function getResizedImgTag($tag, $attributes, $w, $h) {
|
||||
$attr = '';
|
||||
$medias = array();
|
||||
|
||||
// the attribute having an array defines where the image goes
|
||||
foreach($attributes as $attribute => $data) {
|
||||
if(is_array($data)) {
|
||||
$medias = $data;
|
||||
$attr = $attribute;
|
||||
}
|
||||
}
|
||||
// if the image attribute could not be found return
|
||||
if(!$attr || !$medias) return '';
|
||||
|
||||
// try all medias until an existing one is found
|
||||
$media = '';
|
||||
foreach($medias as $media) {
|
||||
if(file_exists(mediaFN($media))) break;
|
||||
$media = '';
|
||||
}
|
||||
if($media === '') return '';
|
||||
|
||||
// replace the array
|
||||
$media = ml($media, array('w' => $w, 'h' => $h, 'crop' => 1), true, '&');
|
||||
$attributes[$attr] = $media;
|
||||
|
||||
// return the full tag
|
||||
return '<' . $tag . ' ' . buildAttributes($attributes) . ' />';
|
||||
}
|
||||
}
|
||||
|
|
1
main.php
1
main.php
|
@ -67,7 +67,6 @@ $showSidebar = true; /* */
|
|||
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
|
||||
?>
|
||||
<?php
|
||||
echo tpl_favicon(array('favicon')); /* DokuWiki: favicon.ico */
|
||||
include('tpl/favicon_tiles.php');
|
||||
?>
|
||||
<?php
|
||||
|
|
|
@ -1,23 +1,73 @@
|
|||
<?php
|
||||
if (!defined('DOKU_INC')) die();
|
||||
?>
|
||||
/**
|
||||
* Embed the various bookmarking icon sizes
|
||||
*
|
||||
* Basically it will first check for an exact image in the right size in the wiki namespace, then for generally named
|
||||
* logos in the wiki namespace and finally it falls back to the logo configured in the template.
|
||||
*
|
||||
*
|
||||
* @author Andreas Gohr <gohr@cosmocode.de>
|
||||
*/
|
||||
use dokuwiki\template\sprintdoc\Template;
|
||||
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-57x57.png', 'images/fav/apple-touch-icon-57x57.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-60x60.png', 'images/fav/apple-touch-icon-60x60.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-72x72.png', 'images/fav/apple-touch-icon-72x72.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-76x76.png', 'images/fav/apple-touch-icon-76x76.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-114x114.png', 'images/fav/apple-touch-icon-114x114.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-120x120.png', 'images/fav/apple-touch-icon-120x120.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-144x144.png', 'images/fav/apple-touch-icon-144x144.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-152x152.png', 'images/fav/apple-touch-icon-152x152.png')); ?>">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo tpl_getMediaFile(array(':wiki:apple-touch-icon-180x180.png', 'images/fav/apple-touch-icon-180x180.png')); ?>">
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
<link rel="icon" type="image/png" href="<?php echo tpl_getMediaFile(array(':wiki:favicon-32x32.png', 'images/fav/favicon-32x32.png')); ?>" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="<?php echo tpl_getMediaFile(array(':wiki:favicon-96x96.png', 'images/fav/favicon-96x96.png')); ?>" sizes="96x96">
|
||||
<link rel="icon" type="image/png" href="<?php echo tpl_getMediaFile(array(':wiki:android-chrome-192x192.png', 'images/fav/android-chrome-192x192.png')); ?>" sizes="192x192">
|
||||
// standard favicon
|
||||
echo Template::getResizedImgTag(
|
||||
'link',
|
||||
array(
|
||||
'rel' => 'shortcut icon',
|
||||
'href' => array('wiki:favicon.ico', 'wiki:favicon.png', tpl_getConf('logo'))
|
||||
),
|
||||
0, 0 // no scaling
|
||||
);
|
||||
|
||||
<meta name="msapplication-square70x70logo" content="<?php echo tpl_getMediaFile(array(':wiki:smalltile.png', 'images/fav/smalltile.png')); ?>" />
|
||||
<meta name="msapplication-square150x150logo" content="<?php echo tpl_getMediaFile(array(':wiki:mediumtile.png', 'images/fav/mediumtile.png')); ?>" />
|
||||
<meta name="msapplication-wide310x150logo" content="<?php echo tpl_getMediaFile(array(':wiki:widetile.png', 'images/fav/widetile.png')); ?>" />
|
||||
<meta name="msapplication-square310x310logo" content="<?php echo tpl_getMediaFile(array(':wiki:largetile.png', 'images/fav/largetile.png')); ?>" />
|
||||
// square apple icons
|
||||
foreach(array(57, 60, 72, 76, 114, 120, 144, 152, 180) as $size) {
|
||||
echo Template::getResizedImgTag(
|
||||
'link',
|
||||
array(
|
||||
'rel' => 'apple-touch-icon',
|
||||
'sizes' => $size . 'x' . $size,
|
||||
'href' => array('wiki:logo-' . $size . 'x' . $size . '.png', 'wiki:logo-square.png', 'wiki:logo.png', tpl_getConf('logo'))
|
||||
),
|
||||
$size, $size
|
||||
);
|
||||
}
|
||||
|
||||
// square favicons
|
||||
foreach(array(32, 96, 192) as $size) {
|
||||
echo Template::getResizedImgTag(
|
||||
'link',
|
||||
array(
|
||||
'rel' => 'icon',
|
||||
'sizes' => $size . 'x' . $size,
|
||||
'href' => array('wiki:logo-' . $size . 'x' . $size . '.png', 'wiki:logo-square.png', 'wiki:logo.png', tpl_getConf('logo'))
|
||||
),
|
||||
$size, $size
|
||||
);
|
||||
}
|
||||
|
||||
// square microsoft icons
|
||||
foreach(array(70, 310) as $size) {
|
||||
echo Template::getResizedImgTag(
|
||||
'meta',
|
||||
array(
|
||||
'name' => 'msapplication-square' . $size . 'x' . $size . 'logo',
|
||||
'content' => array('wiki:logo-' . $size . 'x' . $size . '.png', 'wiki:logo-square.png', 'wiki:logo.png', tpl_getConf('logo'))
|
||||
),
|
||||
$size, $size
|
||||
);
|
||||
}
|
||||
|
||||
// wide micorsoft icons
|
||||
foreach(array(array(310, 150)) as $size) {
|
||||
echo Template::getResizedImgTag(
|
||||
'meta',
|
||||
array(
|
||||
'name' => 'msapplication-wide' . $size[0] . 'x' . $size[1] . 'logo',
|
||||
'content' => array('wiki:logo-' . $size[0] . 'x' . $size[1] . '.png', 'wiki:logo-wide.png', 'wiki:logo.png', tpl_getConf('logo'))
|
||||
),
|
||||
$size[0], $size[1]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue