示例#1
0
 public function getThumbImage($contentEntity, $thumbSlug)
 {
     $thumbEntity = $this->mm()->getThumbStyle($thumbSlug, $this->sm()->getCurrentSite());
     if (empty($thumbEntity)) {
         $thumbEntity = new ThumbStyle();
         $thumbEntity->setSite($this->sm()->getCurrentSite());
         $thumbInfo = $this->tp()->getCurrentSkin()->getThumbStyleDefault($thumbSlug);
         if (!is_null($thumbInfo)) {
             $thumbEntity->setName($thumbInfo['name']);
             $thumbEntity->setSlug($thumbSlug);
             $thumbEntity->setMode($thumbInfo['mode']);
             $thumbEntity->setWidth($thumbInfo['width']);
             $thumbEntity->setHeight($thumbInfo['height']);
         } else {
             $thumbEntity->setName($thumbSlug);
             $thumbEntity->setSlug($thumbSlug);
             $thumbEntity->setMode('scaleResize');
             $thumbEntity->setWidth(100);
             $thumbEntity->setHeight(100);
         }
         $this->em()->persist($thumbEntity);
         $this->em()->flush();
     }
     return $this->mm()->getContentThumbURLWithStyle($contentEntity, $thumbEntity);
 }