/
ThumbnailGenerator.php
52 lines (46 loc) · 1.48 KB
/
ThumbnailGenerator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Concrete\Core\File\Import\Processor;
use Concrete\Core\Config\Repository\Repository;
use Concrete\Core\Entity\File\Version;
use Concrete\Core\File\Import\ImportingFile;
use Concrete\Core\File\Import\ImportOptions;
use Concrete\Core\File\Type\Type as FileType;
class ThumbnailGenerator implements PostProcessorInterface
{
/**
* {@inheritdoc}
*
* @see \Concrete\Core\File\Import\Processor\PostProcessorInterface::getPostProcessPriority()
*/
public function getPostProcessPriority()
{
return 0;
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\File\Import\Processor\ProcessorInterface::readConfiguration()
*/
public function readConfiguration(Repository $config)
{
return $this;
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\File\Import\Processor\PostProcessorInterface::shouldPostProcess()
*/
public function shouldPostProcess(ImportingFile $file, ImportOptions $options, Version $importedVersion)
{
return $file->getFileType()->getGenericType() === FileType::T_IMAGE && $file->getFileType()->isSVG() !== true && $options->isSkipThumbnailGeneration() === false;
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\File\Import\Processor\PostProcessorInterface::postProcess()
*/
public function postProcess(ImportingFile $file, ImportOptions $options, Version $importedVersion)
{
$importedVersion->refreshThumbnails(true);
}
}