Преглед изворни кода

Ticket #4481 - Profile and Group based modules: Update srcset provided to Timeline.

AntonLV пре 3 година
родитељ
комит
0540ce82b5

+ 27 - 9
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -2044,19 +2044,37 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
     protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
     {
         $CNF = &$this->_oConfig->CNF;
+        
+        $iImageId = 0;
+        $sImageMd = $sImageXl = '';
+        if(isset($CNF['FIELD_COVER']) && !empty($aContentInfo[$CNF['FIELD_COVER']])) {
+            $iImageId = (int)$aContentInfo[$CNF['FIELD_COVER']];
+            $sImageMd = $this->_oConfig->getImageUrl($iImageId, ['OBJECT_IMAGES_TRANSCODER_GALLERY']);
+            $sImageXl = $this->_oConfig->getImageUrl($iImageId, ['OBJECT_IMAGES_TRANSCODER_COVER']);
+        }
 
-        $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aEvent['object_id'], $this->getName());
+        if($sImageXl == '' && isset($CNF['FIELD_PICTURE']) && !empty($aContentInfo[$CNF['FIELD_PICTURE']])) {
+            $iImageId = (int)$aContentInfo[$CNF['FIELD_PICTURE']];
+            $sImageMd = $this->_oConfig->getImageUrl($iImageId, ['OBJECT_IMAGES_TRANSCODER_GALLERY']);
+            $sImageXl = $this->_oConfig->getImageUrl($iImageId, ['OBJECT_IMAGES_TRANSCODER_COVER']);
+        }
+
+        if(empty($sImageXl))
+            return [];
 
-        $sSrc = '';
-        if(isset($CNF['FIELD_COVER']) && !empty($aContentInfo[$CNF['FIELD_COVER']]))
-            $sSrc = $oGroupProfile->getCover();
+        $aImage = [
+            'id' => $iImageId, 
+            'url' => $sUrl, 
+            'src' => $sImageXl, 
+            'src_orig' => $sImageXl
+        ];
 
-        if(empty($sSrc) && isset($CNF['FIELD_PICTURE']) && !empty($aContentInfo[$CNF['FIELD_PICTURE']]))
-            $sSrc = $oGroupProfile->getPicture();
+        if(!empty($sImageMd))
+            $aImage['src_medium'] = $sImageMd;
 
-        return empty($sSrc) ? array() : array(
-            array('id' => $aContentInfo[$CNF['FIELD_PICTURE']], 'url' => $sUrl, 'src' => $sSrc, 'src_orig' => $sSrc),
-        );
+        return [
+            $aImage
+        ];
     }
 
     protected function _prepareProfileAndGroupProfile($iGroupProfileId, $iInitiatorId)

+ 9 - 3
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -2211,10 +2211,16 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             if(empty($sImageOrig))
                 $sImageOrig = $sImage;
 
-            $a = array('id' => $aFileInfo['id'], 'url' => $sUrl, 'src' => $sImage);
-            if (CHECK_ACTION_RESULT_ALLOWED === $this->checkAllowedView($aContentInfo))
+            //TODO: Do the same for Groups Cover.
+            $a = ['id' => $aFileInfo['id'], 'url' => $sUrl, 'src' => $sImage];
+            if(CHECK_ACTION_RESULT_ALLOWED === $this->checkAllowedView($aContentInfo)) {
                 $a['src_orig'] = $sImageOrig;
-            $aImages = array($a);
+
+                $sCnfKey = 'OBJECT_IMAGES_TRANSCODER_GALLERY';
+                if(!empty($CNF[$sCnfKey]) && ($sSrcMedium = $this->_oConfig->getImageUrl($aFileInfo['id'], [$sCnfKey])) != '')
+                    $a['src_medium'] = $sSrcMedium;
+            }
+            $aImages = [$a];
         }
 
     	return array(