Css Zend Framework 2:在favicon图标中添加自定义属性

Css Zend Framework 2:在favicon图标中添加自定义属性,css,zend-framework,zend-framework2,Css,Zend Framework,Zend Framework2,我的前端设计师给出html,其中favicon图标显示如下代码 <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/favicon.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/favicon.png"> <link rel="apple-touch-icon-precomposed"

我的前端设计师给出html,其中favicon图标显示如下代码

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/favicon.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/favicon.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/favicon.png">
<link rel="apple-touch-icon-precomposed" href="ico/favicon.png">
<link rel="shortcut icon" href="ico/favicon.png">

但尺寸并没有显示在输出中。任何人都知道如何在favicon中显示自定义属性。提前感谢

HeadLink
helper类严格定义了有效属性的列表

protected $itemKeys = array('charset', 'href', 'hreflang', 'id', 'media', 'rel', 'rev', 'type', 'title', 'extras');
拒绝其他一切。 因此,
size
似乎是helper的无效属性

首先,如果您可以使用纯html输出这些
link
标记,只需使用它即可。 否则,我会想出以下解决方案:

1) 创建自己的
CustomHeadLink
类,扩展原始
HeadLink
,并扩展定义有效属性列表的数组:

<?php

namespace Custom\View\Helper;

use Zend\View\Helper\HeadLink;

class CustomHeadLink extends HeadLink
{
    // added 'sizes' as a new attribute
    protected $itemKeys = array('charset', 'href', 'hreflang', 'id', 'media', 'rel', 'rev', 'type', 'title', 'extras', 'sizes');
}

HeadLink
helper类严格定义有效属性的列表

protected $itemKeys = array('charset', 'href', 'hreflang', 'id', 'media', 'rel', 'rev', 'type', 'title', 'extras');
拒绝其他一切。 因此,
size
似乎是helper的无效属性

首先,如果您可以使用纯html输出这些
link
标记,只需使用它即可。 否则,我会想出以下解决方案:

1) 创建自己的
CustomHeadLink
类,扩展原始
HeadLink
,并扩展定义有效属性列表的数组:

<?php

namespace Custom\View\Helper;

use Zend\View\Helper\HeadLink;

class CustomHeadLink extends HeadLink
{
    // added 'sizes' as a new attribute
    protected $itemKeys = array('charset', 'href', 'hreflang', 'id', 'media', 'rel', 'rev', 'type', 'title', 'extras', 'sizes');
}
看看这个答案:

将“extras”数组键用于非标准属性,如:

$this->headLink(
    array(
        'rel' => 'apple-touch-icon-precomposed',
        'href' => $this->basePath() . '/admin_assets/img/favicon.ico',
        'extras' => array('sizes' => '144x144')
    )
);
看看这个答案:

将“extras”数组键用于非标准属性,如:

$this->headLink(
    array(
        'rel' => 'apple-touch-icon-precomposed',
        'href' => $this->basePath() . '/admin_assets/img/favicon.ico',
        'extras' => array('sizes' => '144x144')
    )
);