Question

I'm creating an extension where I should be able to call the logo which has been uploaded to Magento to show up in the home page.

So I upload the logo to:

Content -> Design -> Configuration -> Edit (Global) -> Header -> Logo Image

enter image description here

I have been investigating how Magento calls the logo:

vendor/magento/module-theme/Block/Html/Header/Logo.php

What would I need to add to my custom module in order to get this logo and show it. Thank you.

Was it helpful?

Solution

You need to inject \Magento\Theme\Block\Html\Header\Logo class in your block/controller and call getLogoSrc() method on its object to get the logo url and getLogoAlt() to get alt text.

Once you have it you can show it image tag in a phtml.

You can see a relevant tutorial here - https://www.mageplaza.com/how-get-logo-url-alt-text-logo-size-magento-2.html

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top