0

I'm unable to change/resize the logo from Magento admin after installing a custom theme. I was finally able to change the logo by putting the .jpg file in pub/media/logo/, but facing issues in resizing the logo(175px * 45p*). I changed/added logo dimensions in /app/design/frontend///layout/default.xml but even that is not working.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_file" xsi:type="string">images/logo.png</argument>
                <argument name="logo_img_width" xsi:type="number">417</argument>
                <argument name="logo_img_height" xsi:type="number">195</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Also I'm not able to disable demo store notice from magento admin.

Any workaround for this?

3 Answers3

2

For anyone looking for this in 2023 the argument name in the the reference block is wrong. it should be:

<argument name="logo_width" xsi:type="number">417</argument>
<argument name="logo_height" xsi:type="number">195</argument>
totneschap
  • 161
  • 11
0

You can change/resize the logo by using admin panel. Go to

Content->configuration->click on edit button on your theme ->Under header upload the required logo ->Put required width and length in logo attribute width and logo attribute length respectively.

Save the Settings and clean cache!

surbhi agr
  • 886
  • 5
  • 22
0

On Magento 2.4.6-p3, it always got the value set from the core: vendor/magento/theme-frontend-blank/Magento_Theme/layout/default.xml:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_width" xsi:type="number">170</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

It does not matter what value I add from the Theme settings: enter image description here

Most likely it is another Magento core bug. The width is retrieved from:

\Magento\Theme\Block\Html\Header\Logo::getLogoWidth

Of course you can do a rewrite of the method:

public function getLogoWidth()
{
    if (empty($this->_data['logo_width'])) {
        $this->_data['logo_width'] = $this->_scopeConfig->getValue(
            'design/header/logo_width',
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );
    }
    return (int)$this->_data['logo_width'];
}

By removing the IF condition. or Rewrite this file in your theme .../header/logo.phtml file . OR do a patch , see how: https://magento.stackexchange.com/a/315195/6204

Attila Naghi
  • 4,013
  • 3
  • 37
  • 71