Home » Magento, Magento 219 May 2016

Magento 2: Get Logo URL, ALT Text, Logo Height & Width

This article shows how we can get the URL and ALT text of a Logo of the Magento 2 website. The article also include code to fetch Logo Height and Width.

Logo Image Width and Logo Image Height is fetched from Configuration Settings (Stores -> Settings -> Configuartion -> General -> Design -> Header).

Below is a block class of my custom module (Chapagain_HelloWorld). I have injected object of Logo block in the constructor of my module’s block class.

app/code/Chapagain/HelloWorld/Block/HelloWorld.php

See more functions in vendor/magento/module-theme/Block/Html/Header/Logo.php.

Now, we use can the function in our template (.phtml) file.

Using Object Manager

Hope this helps. Thanks.

Magento 2

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed