File tree Expand file tree Collapse file tree 11 files changed +220
-0
lines changed Expand file tree Collapse file tree 11 files changed +220
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Marlosoft \BackendImage \Block \Page ;
4
+
5
+ use Magento \Backend \Model \UrlInterface ;
6
+ use Marlosoft \BackendImage \Helper \Data ;
7
+
8
+ /**
9
+ * Class Header
10
+ * @package Marlosoft\BackendImage\Block\Page
11
+ * @property Data $_backendData
12
+ */
13
+ class Header extends \Magento \Backend \Block \Page \Header
14
+ {
15
+ /** @var string $customPath */
16
+ private $ customPath ;
17
+
18
+ /** @return void */
19
+ protected function _construct ()
20
+ {
21
+ parent ::_construct ();
22
+ $ this ->customPath = $ this ->_backendData ->getCustomPath ($ this ->getData ('show_part_size ' ));
23
+ }
24
+
25
+ /** @return bool */
26
+ public function hasLogoImageSrc ()
27
+ {
28
+ /** @noinspection PhpUndefinedMethodInspection */
29
+ return empty ($ this ->customPath ) ? parent ::hasLogoImageSrc () : true ;
30
+ }
31
+
32
+ /** @return string */
33
+ public function getLogoImageSrc ()
34
+ {
35
+ /** @noinspection PhpUndefinedMethodInspection */
36
+ return empty ($ this ->customPath ) ? parent ::getLogoImageSrc () : $ this ->customPath ;
37
+ }
38
+
39
+ /**
40
+ * @param string $fileId
41
+ * @param array $params
42
+ * @return string
43
+ */
44
+ public function getViewFileUrl ($ fileId , array $ params = [])
45
+ {
46
+ if (empty ($ this ->customPath )) {
47
+ return parent ::getViewFileUrl ($ fileId , $ params );
48
+ }
49
+
50
+ $ mediaUrl = $ this ->_urlBuilder ->getBaseUrl (['_type ' => UrlInterface::URL_TYPE_MEDIA ]);
51
+ return $ mediaUrl . Data::UPLOAD_DIRECTORY . $ this ->customPath ;
52
+ }
53
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Marlosoft \BackendImage \Helper ;
4
+
5
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
6
+
7
+ /**
8
+ * Class Data
9
+ * @package Marlosoft\BackendImage\Helper
10
+ */
11
+ class Data extends \Magento \Backend \Helper \Data
12
+ {
13
+ const LOGO = 'logo ' ;
14
+ const SIZE_LOGO = 'logo ' ;
15
+ const SIZE_ICON = 'icon ' ;
16
+ const UPLOAD_DIRECTORY = 'admin/backend_image/ ' ;
17
+ const LOGO_CONFIG_PATH = 'admin/backend_image/logo ' ;
18
+ const ICON_CONFIG_PATH = 'admin/backend_image/icon ' ;
19
+
20
+ /**
21
+ * @param string $size
22
+ * @return string|null
23
+ */
24
+ public function getCustomPath ($ size )
25
+ {
26
+ if ($ size === self ::SIZE_LOGO ) {
27
+ return $ this ->getCustomLogo ();
28
+ }
29
+
30
+ if ($ size === self ::SIZE_ICON ) {
31
+ return $ this ->getCustomIcon ();
32
+ }
33
+
34
+ return null ;
35
+ }
36
+
37
+ /** @return string */
38
+ private function getCustomLogo ()
39
+ {
40
+ return $ this ->scopeConfig ->getValue (self ::LOGO_CONFIG_PATH , ScopeConfigInterface::SCOPE_TYPE_DEFAULT );
41
+ }
42
+
43
+ /** @return string */
44
+ private function getCustomIcon ()
45
+ {
46
+ return $ this ->scopeConfig ->getValue (self ::ICON_CONFIG_PATH , ScopeConfigInterface::SCOPE_TYPE_DEFAULT );
47
+ }
48
+ }
Original file line number Diff line number Diff line change
1
+ Admin Custom Backend Image
2
+ ==========================
3
+
4
+ Custom admin backend image for Magento 2.x
5
+
6
+
7
+ ## Installation via Composer
8
+ ``` bash
9
+ composer require marlosoft/module-backend-image
10
+ ```
11
+
12
+ ## Manual Installation
13
+ 1 . Download the chat plugin source.
14
+ 2 . Create new folder ` app/code/Marlosoft/BackendImage/ ` .
15
+ 3 . Copy all source files into the newly created directory.
16
+ 4 . Run setup upgrade command.
17
+ ``` bash
18
+ php bin/magento setup:upgrade
19
+ ```
20
+ 5. Run cache flush command.
21
+ ` ` ` bash
22
+ php bin/magento cache:flush
23
+ ` ` `
24
+ 6. That' s it! The extension should be already installed.
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " marlosoft/module-backend-image" ,
3
+ "description" : " Custom admin backend image for Magento 2.x" ,
4
+ "type" : " magento2-module" ,
5
+ "version" : " 1.0.0" ,
6
+ "license" : " MIT" ,
7
+ "autoload" : {
8
+ "files" : [
9
+ " registration.php"
10
+ ],
11
+ "psr-4" : {
12
+ "Marlosoft\\ BackendImage\\ " : " "
13
+ }
14
+ },
15
+ "require" : {
16
+ "php" : " >=5.6"
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:module:Magento_Config:etc/system_file.xsd" >
3
+ <system >
4
+ <section id =" admin" >
5
+ <group id =" backend_image" sortOrder =" 10" showInDefault =" 1" showInWebsite =" 0" showInStore =" 0" >
6
+ <label >Admin Backend Image</label >
7
+ <field id =" logo" translate =" label comment" type =" image" sortOrder =" 100" showInDefault =" 1" showInWebsite =" 0" showInStore =" 0" >
8
+ <label >Login Logo Image</label >
9
+ <backend_model >Magento\Config\Model\Config\Backend\Image</backend_model >
10
+ <upload_dir config =" system/filesystem/media" scope_info =" 1" >admin/backend_image</upload_dir >
11
+ <base_url type =" media" scope_info =" 1" >admin/backend_image</base_url >
12
+ </field >
13
+ <field id =" icon" translate =" label comment" type =" image" sortOrder =" 100" showInDefault =" 1" showInWebsite =" 0" showInStore =" 0" >
14
+ <label >Admin Icon Image</label >
15
+ <backend_model >Magento\Config\Model\Config\Backend\Image</backend_model >
16
+ <upload_dir config =" system/filesystem/media" scope_info =" 1" >admin/backend_image</upload_dir >
17
+ <base_url type =" media" scope_info =" 1" >admin/backend_image</base_url >
18
+ </field >
19
+ </group >
20
+ </section >
21
+ </system >
22
+ </config >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:ObjectManager/etc/config.xsd" >
3
+ <preference for =" Magento\Backend\Block\Page\Header" type =" Marlosoft\BackendImage\Block\Page\Header" />
4
+ <preference for =" Magento\Backend\Helper\Data" type =" Marlosoft\BackendImage\Helper\Data" />
5
+ </config >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:Module/etc/module.xsd" >
3
+ <module name =" Marlosoft_BackendImage" setup_version =" 1.0.0" >
4
+ <sequence >
5
+ <module name =" Magento_Backend" />
6
+ </sequence >
7
+ </module >
8
+ </config >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Magento \Framework \Component \ComponentRegistrar ;
4
+
5
+ ComponentRegistrar::register (
6
+ ComponentRegistrar::MODULE ,
7
+ 'Marlosoft_BackendImage ' ,
8
+ __DIR__
9
+ );
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <page xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:View/Layout/etc/page_configuration.xsd" >
3
+ <update handle =" admin_login" />
4
+ <body >
5
+ <referenceBlock name =" logo" >
6
+ <arguments >
7
+ <argument name =" show_part_size" xsi : type =" string" >logo</argument >
8
+ </arguments >
9
+ </referenceBlock >
10
+ </body >
11
+ </page >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <page xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" layout =" admin-1column" xsi : noNamespaceSchemaLocation =" urn:magento:framework:View/Layout/etc/page_configuration.xsd" >
3
+ <head >
4
+ <css src =" Marlosoft_BackendImage::css/styles.css" />
5
+ </head >
6
+ <body >
7
+ <referenceBlock name =" logo" >
8
+ <arguments >
9
+ <argument name =" show_part_size" xsi : type =" string" >icon</argument >
10
+ </arguments >
11
+ </referenceBlock >
12
+ </body >
13
+ </page >
You can’t perform that action at this time.
0 commit comments