1
0
Эх сурвалжийг харах

#2966 Use the first photo as cover - cover

RomanL 6 жил өмнө
parent
commit
c11e8519c2

+ 16 - 0
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -601,6 +601,22 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
 
         // get thumb url
         list($sPhotoThumb, $sPhotoGallery) = $this->getUnitThumbAndGallery($aData);
+		
+		if ($sPhotoGallery == '' && isset($CNF['PARAM_USE_GALERY_AS_COVER']) && getParam($CNF['PARAM_USE_GALERY_AS_COVER']) == 'on'){
+			if(!empty($CNF['OBJECT_STORAGE_PHOTOS'])){
+				$sStorage = $CNF['OBJECT_STORAGE_PHOTOS'];
+				$oStorage = BxDolStorage::getObjectInstance($sStorage); 
+				list($oTranscoder, $oTranscoderPreview) = $this->getAttachmentsImagesTranscoders($sStorage);
+				$aGhostFiles = $oStorage->getGhosts ($this->getModule()->serviceGetContentOwnerProfileId($aData[$CNF['FIELD_ID']]), $aData[$CNF['FIELD_ID']]);
+				if ($aGhostFiles){
+					foreach ($aGhostFiles as $k => $a) {
+						$sPhotoGallery = $oTranscoder->getFileUrl($a['id']);
+						$sPhotoThumb  = $oTranscoderPreview->getFileUrl($a['id']);
+						break; 
+					}
+				}
+			}
+		}
 
         // get entry url
         $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);