4

I would like to change both the logo in the login admin portal and the Magento icon at the top left of the admin menu.

What is the easiest way to do that, according images I want to upload are PNG files (I am not familiar with SVG format) Thanks for your help.

  • To modify the default admin logo with custom theme, check here. – Pratik Oza Dec 17 '17 at 6:44
6

In order to change top left logo of the admin menu you have to create in your custom module view/adminhtml/layout/default.xml file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header">
            <block class="Magento\Backend\Block\Page\Header" name="logo" before="-">
                <arguments>
                    <argument name="show_part" xsi:type="string">logo</argument>
                    <argument name="edition" translate="true" xsi:type="string">Community Edition</argument>
                    <argument name="logo_image_src" xsi:type="string">images/custom-admin-icon.svg</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

Place custom-admin-icon.svg with height 25px and width 41px into CustomModule/view/web/images/custom-admin-icon.svg

For the Admin Login page create new view/adminhtml/layout/admin_login.xml file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-login" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="logo">
        <arguments>
            <argument name="logo_image_src" xsi:type="string">images/custom-admin-logo.svg</argument>
        </arguments>
    </referenceBlock>
</body>

Feel free to use PNG files instead of SVG.

  • I placed my custom Icon in my custom module at the location you specified, but after uploading and clearing all caches, generation and pub/static, I only get the error image not found in pub/static/adminhtml/Magento/backend/en_US/images, so the generator is not placing the image where magento expects it to be. I've followed your instructions exactly, could there be something missing? – Jonathan Eltgroth Jun 27 '16 at 15:38
  • Can you please provide full path of the image and full path of the layout file? Also, do you run in developer mode? Thanks – Max Pronko Jun 27 '16 at 18:10
  • I have the image in the custom module at app/code/Metal/Backend/view/web/images/logo_288x16.png and the layout file is at app/code/Metal/Backend/view/adminhtml/layout/admin_login.xml. The file matches the block of code above except for the filepath in the argument, which is images/logo_288x16.png. This results is Magento correctly looking for my image, but it seems that magento expects it to be in the backend theme directory, not the custom modules, hence my confusion. – Jonathan Eltgroth Jun 28 '16 at 13:43
  • @MaxPronko can not we do it using custom theme or is it necessary to create custom module ? - magento.stackexchange.com/questions/207833/… – Slimshadddyyy Jan 3 '18 at 8:36
4

There are 2 small changes in 'Max Pronko' module:

1) Add Namespace_Modulename before image path

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-login" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="logo">
        <arguments>
            <argument name="logo_image_src" xsi:type="string">Namespace_Modulename/images/custom-admin-logo.svg</argument>
        </arguments>
    </referenceBlock>
</body>

2) And change directory: CustomModule/view/web/images/custom-admin-icon.svg

to

CustomModule/view/adminhtml/web/images/custom-admin-icon.svg
  • Hello @Gmb, I have created both files in my custom module and also update your changes and clean cache also but still showing magento logo. – Vinaya Maheshwari Jul 4 '17 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.