15/08/2022
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
There are the steps to get logo url, image url, Alt text and logo size in magento 2
Directory
app/code/VendorName/ModuleName/Block/Demo.php
Content of Demo.php
<?php
namespace VendorName\ModuleName\Block;
class Demo extends \Magento\Framework\View\Element\Template
{
protected $_logo;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Theme\Block\Html\Header\Logo $logo,
array $data = []
)
{
$this->_logo = $logo;
parent::__construct($context, $data);
}
/**
* Get logo image URL
*
* @return string
*/
public function getLogoSrc()
{
return $this->_logo->getLogoSrc();
}
/**
* Get logo text
*
* @return string
*/
public function getLogoAlt()
{
return $this->_logo->getLogoAlt();
}
/**
* Get logo width
*
* @return int
*/
public function getLogoWidth()
{
return $this->_logo->getLogoWidth();
}
/**
* Get logo height
*
* @return int
*/
public function getLogoHeight()
{
return $this->_logo->getLogoHeight();
}
}
?>
echo $block->getLogoSrc() . '<br />';
echo $block->getLogoAlt() . '<br />';
echo $block->getLogoWidth() . '<br />';
echo $block->getLogoHeight() . '<br />';
If you want any kind of help please visit our Magento 2 Development Service and get a Quote.