Browse code

[Update] Rework moduleavatar logic

Sebastian Zoglowek authored on23/05/2022 23:23:13
Showing2 changed files
... ...
@@ -38,12 +38,7 @@ class ModuleAvatar extends Module
38 38
      */
39 39
     protected $strTemplate = 'memberExtension_avatar';
40 40
 
41
-    /**
42
-     * Default avatar file path
43
-     *
44
-     * @var string
45
-     */
46
-    private static $strDefaultPath = 'bundles/contaomemberextension/avatar.png';
41
+    const DEFAULT_PICTURE = 'bundles/contaomemberextension/avatar.png';
47 42
 
48 43
     /**
49 44
      * Return a wildcard in the back end
... ...
@@ -106,21 +101,17 @@ class ModuleAvatar extends Module
106 101
         {
107 102
             $objFile = FilesModel::findByUuid(Config::get('defaultAvatar'));
108 103
         }
109
-        else
110
-        {
111
-            $objTemplate->singleSRC = self::$strDefaultPath;
112
-        }
113 104
 
114 105
         // If file does not exist use default image
115
-        if ($objFile === null || !is_file($projectDir . '/' . $objFile->path))
116
-        {
117
-            $objTemplate->singleSRC = self::$strDefaultPath;
118
-        }
119
-        else
106
+        if (null !== $objFile || is_file($projectDir . '/' . $objFile->path))
120 107
         {
121 108
             $objTemplate->noAvatar = false;
122 109
             $this->singleSRC = $objFile->path;
123 110
             $this->addImageToTemplate($this->Template, $this->arrData);
124 111
         }
112
+        else
113
+        {
114
+            $objTemplate->singleSRC = self::DEFAULT_PICTURE;
115
+        }
125 116
     }
126 117
 }
... ...
@@ -4,7 +4,7 @@
4 4
 
5 5
 <?php if($this->noAvatar):?>
6 6
   <figure class="image_container">
7
-    <img src="<?= $this->singleSRC; ?>" itemprop="image">
7
+    <img src="<?= $this->singleSRC; ?>" width="200" height="200" itemprop="image">
8 8
   </figure>
9 9
 <?php else: ?>
10 10
   <figure class="image_container">