Cameron
Cameron

Reputation: 28803

Display a PNG favicon in CakePHP

How do I show a PNG favicon in CakePHP? I'm currently using $this->Html->meta('icon') but it looks for .ico in the root. How do I change it so that it looks for .png?

Upvotes: 12

Views: 17591

Answers (6)

AndreyP
AndreyP

Reputation: 2678

CakePHP 3.5:

echo $this->Html->meta('icon', 'favicon.png', ['type'=>'image/png'])

will generate

<link href="/favicon.png" type="image/png" rel="icon"/>
<link href="/favicon.png" type="image/png" rel="shortcut icon"/>

Upvotes: 5

Dzoki
Dzoki

Reputation: 739

$this->Html->meta('icon', $this->Html->url('/favicon.png'));

Upvotes: 21

Iyke Perry
Iyke Perry

Reputation: 331

Try to comment out the $this->html->meta('icon') from the default layout,

this worked for me

Upvotes: 0

Suman Kalyan
Suman Kalyan

Reputation: 480

This would be better to use:

<?php
echo $this->Html->meta('favicon.ico','img/favicon.ico',array('type' => 'icon'));
?>

Upvotes: 8

Anubhav
Anubhav

Reputation: 1623

Ideally you should put your favicon.ico inside webroot folder, cakephp framework will do rest of the things by itself.

Upvotes: 0

Rusty Divine
Rusty Divine

Reputation: 3492

I had to put the icon into the /img/ folder - it just wouldn't accept it in the root folder.

Upvotes: 0

Related Questions