简体   繁体   中英

How to add ads image in header magento 2

how to add image in header 320x72(heightxwidth) in magento 2. header and footer file and showing in app->design->frontend-> or shopping\\vendor\\magento\\theme-frontend-blank\\Magento_Theme\\layout . suggest me changes step by step.

Step 1. Make new theme in Magento 2 follow below directory

app / design / frontend / / / Magento_Theme / templates / html

Step 2. Copy header.phtml files from vendor\\magento\\module-theme\\view\\frontend\\templates\\html and paste in app / design / frontend / / / Magento_Theme / templates / html

Step 3. Now you can change header.phtml files.

    Image can add in header by below code.

<?php 
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();  

        $storeManager = $_objectManager->get('Magento\Store\Model\StoreManagerInterface'); 

        $currentStore = $storeManager->getStore();

        $mediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); 
    ?>

    <img scr="<?php echo $mediaUrl.'/image.jpg' ?>">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM