public function cleanupThumbs(AbstractWatermarkEntity $entity, \SystemPlugin_Imagine_Manager $imagineManager) { $imagineManager->setModule('CmfcmfMediaModule'); $qb = $this->getEntityManager()->createQueryBuilder(); $qb->select('m')->from('CmfcmfMediaModule:Media\\AbstractMediaEntity', 'm')->leftJoin('m.collection', 'c')->where($qb->expr()->eq('c.watermark', ':watermark'))->setParameter('watermark', $entity); /** @var AbstractMediaEntity[] $media */ $media = $qb->getQuery()->execute(); foreach ($media as $medium) { $imagineManager->removeObjectThumbs($medium->getImagineId()); } }
protected function getIconThumbnailByFileExtension(AbstractFileEntity $entity, $width, $height, $format = 'html', $mode = 'outbound', $optimize = true, $forceExtension = false) { return false; // @todo Re-enable? if (!in_array($mode, ['inset', 'outbound'])) { throw new \InvalidArgumentException('Invalid mode requested.'); } $mode = 'inset'; $availableSizes = [16, 32, 48, 512]; foreach ($availableSizes as $size) { if ($width <= $size && $height <= $size) { break; } } $extension = $forceExtension ? $forceExtension : pathinfo($entity->getFileName(), PATHINFO_EXTENSION); $icon = '@CmfcmfMediaModule/Resources/public/images/file-icons/' . $size . 'px/' . $extension . '.png'; try { $path = $this->getPathToFile($icon); } catch (\InvalidArgumentException $e) { $icon = '@CmfcmfMediaModule/Resources/public/images/file-icons/' . $size . 'px/_blank.png'; $path = $this->getPathToFile($icon); } $this->imagineManager->setPreset($this->getPreset($entity, $path, $width, $height, $mode, $optimize)); $path = $this->imagineManager->getThumb($path, $entity->getImagineId()); $url = \System::getBaseUri() . '/' . $path; switch ($format) { case 'url': return $url; case 'html': return '<img src="' . $url . '" />'; case 'path': return $path; } throw new \LogicException(); }