Explorar el Código

Ticket #4971 - Build-in API support: Image dimensions.

AntonLV hace 8 meses
padre
commit
94247d28d0
Se han modificado 2 ficheros con 14 adiciones y 3 borrados
  1. 13 3
      inc/utils.inc.php
  2. 1 0
      modules/boonex/resources/install/sql/install.sql

+ 13 - 3
inc/utils.inc.php

@@ -2699,8 +2699,7 @@ function bx_api_get_image($mixedStorage, $iId)
         $sStorage = $mixedStorage;
         $sStorage = $mixedStorage;
 
 
     $sUrl = '';
     $sUrl = '';
-    $iWidth = 500;
-    $iHeight = 500;
+    $iWidth = $iHeight = 0;
     if($sTranscoder && ($oTranscoder = BxDolTranscoder::getObjectInstance($sTranscoder))) {
     if($sTranscoder && ($oTranscoder = BxDolTranscoder::getObjectInstance($sTranscoder))) {
         $sUrl = $oTranscoder->getFileUrl($iId);
         $sUrl = $oTranscoder->getFileUrl($iId);
 
 
@@ -2709,7 +2708,7 @@ function bx_api_get_image($mixedStorage, $iId)
             $iHeight = (int)$aSize['h'];
             $iHeight = (int)$aSize['h'];
         }
         }
     }
     }
-    
+
     if(!$sUrl && ($oS = BxDolStorage::getObjectInstance($sStorage))) {
     if(!$sUrl && ($oS = BxDolStorage::getObjectInstance($sStorage))) {
         $sUrl = $oS->getFileUrlById($iId);
         $sUrl = $oS->getFileUrlById($iId);
 
 
@@ -2720,6 +2719,17 @@ function bx_api_get_image($mixedStorage, $iId)
         }
         }
     }
     }
 
 
+    if(!$iWidth && !$iHeight && $sUrl) {
+        $aSize = BxDolImageResize::getInstance()->getImageSize($sUrl);
+        $iWidth = (int)$aSize['w'];
+        $iHeight = (int)$aSize['h'];
+    }
+
+    if(!$iWidth && !$iHeight) {
+        $iWidth = 500;
+        $iHeight = 500;
+    }
+
     return !empty($sUrl) ? [
     return !empty($sUrl) ? [
         'storage' => $sStorage,
         'storage' => $sStorage,
         'src' => $sUrl,
         'src' => $sUrl,

+ 1 - 0
modules/boonex/resources/install/sql/install.sql

@@ -51,6 +51,7 @@ CREATE TABLE IF NOT EXISTS `bx_resources_covers` (
   `mime_type` varchar(128) NOT NULL,
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `size` bigint(20) NOT NULL,
   `size` bigint(20) NOT NULL,
+  `dimensions` varchar(12) NOT NULL,
   `added` int(11) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `private` int(11) NOT NULL,
   `private` int(11) NOT NULL,