system.xml
<field id="logo" translate="label" type="image" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Logo Image</label>
<comment>Allowed file types:PNG, GIF, JPG, JPEG, SVG.</comment>
<backend_model>Vendor\Module\Model\Config\Backend\Image\logo</backend_model>
<base_url type="media" scope_info="1">folder/folder/logo</base_url>
</field>
/app/code/Vendor/Module/Model/Config/Backend/Image/Logo.php
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* System config Logo image field backend model
*/
namespace Vendor\Module\Model\Config\Backend\Image;
class Logo extends \Magento\Config\Model\Config\Backend\Image {
/**
* The tail part of directory path for uploading
*
*/
const UPLOAD_DIR = 'folder/folder/logo';
/**
* Return path to the directory for upload file
*
* @return string
* @throw \Magento\Framework\Exception\LocalizedException
*/
protected function _getUploadDir() {
return $this-->_mediaDirectory->getAbsolutePath($this->_appendScopeInfo(self::UPLOAD_DIR));
}
/**
* Makes a decision about whether to add info about the scope.
*
* @return boolean
*/
protected function _addWhetherScopeInfo() {
return true;
}
/**
* Getter for allowed extensions of uploaded files.
*
* @return string[]
*/
protected function _getAllowedExtensions() {
return ['jpg', 'jpeg', 'gif', 'png', 'svg'];
}
}
1 Comment
Parker Tselee · April 22, 2022 at 7:35 pm
Oh my goodness! Awesome article dude! Thank you so much, However I am experiencing difficulties with your RSS. I don’t understand why I am unable to subscribe to it. Is there anyone else having identical RSS issues? Anyone who knows the answer can you kindly respond? Thanks!!