---
title: "How to Get Logo URL, Alt Text, Logo Size in Magento 2"
url: "https://magecomp.com/blog/get-logo-url-alt-text-logo-size-magento-2/"
date: "2021-10-29T13:17:46+00:00"
modified: "2025-02-18T06:02:05+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 374
reading_time: "2 min read"
summary: "Hello Magento Friends,
It’s an interesting topic for the day. How to Get Logo URL, Alt Text, Logo Size in Magento 2."
description: "Your brand logo is your identity and it require information like URL, Alt Teatx and Size that helps in SEO ranking. Learn How to Get Logo URL, Alt Text, Logo..."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "MAGENTO 2 : How to Add New Custom Action In Sales Order"
    url: "https://magecomp.com/blog/magento-2-add-new-custom-action-sales-order-grid/"
  - title: "How to Create Credit Memo Programmatically Using Root Script in Magento 2?"
    url: "https://magecomp.com/blog/create-credit-memo-programmatically-using-root-script-magento-2/"
  - title: "How to Login in to Magento 2 Admin without Password? (Using Root Script)"
    url: "https://magecomp.com/blog/login-in-to-magento-2-admin-without-password-using-root-script/"
---

# How to Get Logo URL, Alt Text, Logo Size in Magento 2

_Published: October 29, 2021_  
_Author: Dhiren Vasoya_  

![How to Get Logo URL Alt Text Logo Size in Magento 2](https://magecomp.com/blog/wp-content/uploads/2021/10/How-to-Get-Logo-URL-Alt-Text-Logo-Size-in-Magento-2-1024x512.webp)

**Hello Magento Friends,**

It’s an interesting topic for the day. How to Get Logo URL, Alt Text, Logo Size in Magento 2.
[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-Malware-Removal-CTA-5.webp)](https://magecomp.com/magento-malware-removal.html)

The logo is the identity of your brand. When you apply the logo to your store you need to determine information like Logo Size, Logo URL, and Alt Text. These details are totally important to increase your brand uniqueness and also your SEO rankings.
Logo URL refers to the link the user is redirected to when he/she clicks on the logo. Logo size refers to the height and width of the logo image. Alt Text refers to the unique content on the logo. You need these three elements for your brand – a relevant logo URL, a unique alt text, and perfect logo size.
Let’s see the steps on How to Get Logo URL, Alt Text, Logo Size in Magento 2.
## Steps to Get Logo URL, Alt Text, Logo Size in Magento 2:
**Step 1:** Use the below code in your block class
**app\code\Vendor\Extension\Block\Logo.php**

```
<?php
namespace VendorExtensionBlock;
class Logo extends MagentoFrameworkViewElementTemplate
{
    protected $_logo;
    protected $_template = “logo.phtml”;

    public function __construct(
        MagentoBackendBlockTemplateContext $context,
        MagentoThemeBlockHtmlHeaderLogo $logo,
        array $data = []
    )
    {
        $this->_logo = $logo;
        parent::__construct($context, $data);
    }

     //Get logo image URL
    public function getLogoSrc()
    {
        return $this->_logo->getLogoSrc();
    }

    //Get logo text
    public function getLogoAlt()
    {
        return $this->_logo->getLogoAlt();
    }

    //Get logo width
    public function getLogoWidth()
    {
        return $this->_logo->getLogoWidth();
    }

    //Get logo height
    public function getLogoHeight()
    {
        return $this->_logo->getLogoHeight();
    }
}
?>
```

[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-3.webp)](https://magecomp.com/magento-performance-optimization.html)

**Step 2:** Call function in template (.phtml) file at the below path
**app\code\Vendor\Extension\view\frontend\templates\ logo.phtml**

```
<?php
echo $block->getLogoSrc() . '<br />';
echo $block->getLogoAlt() . '<br />';
echo $block->getLogoWidth() . '<br />';
echo $block->getLogoHeight() . '<br />';
?>
```

## Conclusion:
This way you can Get Logo URL, Alt Text, Logo Size in Magento 2. You can even [**change the logo in Magento 2**](https://magecomp.com/blog/change-logo-magento-2/). If you have any issues let me know through the comment section. Share the article with your friends and colleagues. Stay tuned for more.
**[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-5.webp)](https://magecomp.com/services/hyva-theme-development/)**

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/get-logo-url-alt-text-logo-size-magento-2/](https://magecomp.com/blog/get-logo-url-alt-text-logo-size-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-10-01 12:59:15 UTC_  
