AntonLV 8 лет назад
Родитель
Сommit
0e06d2de78

+ 25 - 1
inc/classes/BxDolTemplate.php

@@ -950,6 +950,29 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
         return $this->_oTemplateFunctions;
     }
 
+    /**
+     * Get image MIME type.
+     * 
+     * @param string $sExtension - image file's extension.
+     * @return string with MIME type. 
+     */
+    function getImageMimeType($sExtension)
+    {
+    	$sExtension = strtolower($sExtension);
+    
+    	$sResult = '';
+    	switch($sExtension) {
+    		case 'svg':
+    			$sResult = 'svg+xml';
+    			break;
+    
+    		default:
+    			$sResult = $sExtension;
+    	}
+    
+    	return 'data:image/' . $sResult;
+    }
+
     /**
      * Get icon template in dependence of a value, provided in $mixedId.
      * 
@@ -2475,11 +2498,12 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
         $iFileSize = 0;
         if($this->_bImagesInline && ($iFileSize = filesize($sPath)) !== false && $iFileSize < $this->_iImagesMaxSize) {
             $aFileInfo = pathinfo($sPath);
-            return "data:image/" . strtolower($aFileInfo['extension']) . ";base64," . base64_encode(file_get_contents($sPath));
+            return $this->getImageMimeType($aFileInfo['extension']) . ";base64," . base64_encode(file_get_contents($sPath));
         }
 
         return false;
     }
+
     /**
      * Get file name where the template would be cached.
      *

+ 1 - 1
studio/template/scripts/BxBaseStudioDesigner.php

@@ -110,7 +110,7 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner
         $aTmplVarsTemplates = array ();
         foreach($aTemplates as $sUri => $aTemplate) {
         	$sIcon = $this->getModuleIcon($aTemplate, 'store');
-	        $bIcon = strpos($sIcon, '.') === false;
+	        $bIcon = strpos($sIcon, '.') === false && strcmp(substr($sIcon, 0, 10), 'data:image') != 0;
 
             $aTmplVarsTemplates[] = array(
                 'uri' => $sUri,

+ 1 - 1
studio/template/scripts/BxBaseStudioWidgets.php

@@ -104,7 +104,7 @@ class BxBaseStudioWidgets extends BxDolStudioWidgets
             }
 
             $sIcon = $this->getIcon($aWidget);
-            $bIcon = strpos($sIcon, '.') === false;
+            $bIcon = strpos($sIcon, '.') === false && strcmp(substr($sIcon, 0, 10), 'data:image') != 0;
 
             $sNotices = !empty($this->aWidgetsNotices[$aWidget['id']]) ? $this->aWidgetsNotices[$aWidget['id']] : '';