elMarquis
elMarquis

Reputation: 7720

Magento Admin - Change the logo text field to an image upload

I'm using Magento v1.4.2

In the Admin under System > Config > Design > Header

is a field called Logo Image Src which is a text field.

I want to change this to an image upload field similar to the one used for Favicon icon (under HTML Head further up the page).

I found a list of most of the Admin fields in: app\code\core\Mage\Core\etc\system.xml

But I don't see the favicon or Logo field here. If I could find where these fields are getting declared I'm guessing it wouldn't be too hard to look at the favicon field and do something similar for the logo one.

Does anyone know a way I can do this?

Upvotes: 0

Views: 2311

Answers (2)

elMarquis
elMarquis

Reputation: 7720

Got it working. As Cags pointed out, the favicon upload field and logo field are declared in: [app\code\core\Mage\Page\etc\system.xml]

I identified the favicon part, which looks like this:

<shortcut_icon translate="label comment">
    <label>Favicon Icon</label>
    <comment>Allowed file types: ICO, PNG, GIF, JPEG, APNG, SVG. Not all browsers support all these formats!</comment>
    <frontend_type>image</frontend_type>
    <backend_model>adminhtml/system_config_backend_image_favicon</backend_model>
    <base_url type="media" scope_info="1">favicon</base_url>
    <sort_order>5</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</shortcut_icon>

And I found the section for the logo:

 <logo_src translate="label">
    <label>Logo Image Src</label>
    <frontend_type>text</frontend_type>
    <sort_order>10</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</logo_src>

So copying the structure of the favicon block, I changed my logo block to:

<logo_src translate="label comment">
    <label>Logo Image Source</label>
    <comment>Allowed file types: PNG, GIF, JPEG. Not all browsers support all these formats!</comment>
    <frontend_type>image</frontend_type>
    <backend_model>adminhtml/system_config_backend_image_logo</backend_model>
    <base_url type="media" scope_info="1">logo</base_url>
    <sort_order>10</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</logo_src>

Notice the favicon block has:

<backend_model>adminhtml/system_config_backend_image_favicon</backend_model>

This means that it references the file: [app\code\core\Mage\Adminhtml\Model\System\Config\Backend\Image\Favicon.php].

So I made a copy of that file in the same directory and named it Logo.php. This means I can set the equivalent field in my Logo block to:

<backend_model>adminhtml/system_config_backend_image_logo</backend_model>

In the file Logo.php I basically changed some references from favicon to logo.

In the class decleration: class Mage_Adminhtml_Model_System_Config_Backend_Image_Logo extends Mage_Adminhtml_Model_System_Config_Backend_Image

And on line 41: const UPLOAD_DIR = 'logo';

And also amended the accepted filetypes to just png, gif, jpeg and jpg:

protected function _getAllowedExtensions()
    {
        return array('png', 'gif', 'jpeg', 'jpg');
    }

There are probably better ways of doing this without modifying core files, but this worked for me.

Upvotes: 1

Peter O&#39;Callaghan
Peter O&#39;Callaghan

Reputation: 6186

The reason you can't find it is because it's not in the Core module, you will find it in the Page module [app\code\core\Mage\Page\etc\system.xml].

Upvotes: 1

Related Questions