27 private $sourceContentType;
37 private $contentType =
'image';
77 if (isset($miscParams[
'image_type'])) {
78 $this->sourceContentType = $miscParams[
'image_type'];
79 unset($miscParams[
'image_type']);
81 $this->sourceContentType = $this->contentType;
84 $this->context = $context;
85 $this->filePath = $filePath;
86 $this->miscParams = $miscParams;
95 return $this->context->getBaseUrl() . DIRECTORY_SEPARATOR . $this->getImageInfo();
103 return $this->contentType;
111 return $this->context->getPath() . DIRECTORY_SEPARATOR . $this->getImageInfo();
119 return $this->mediaConfig->getBaseMediaPath()
120 . DIRECTORY_SEPARATOR . ltrim($this->
getFilePath(), DIRECTORY_SEPARATOR);
130 return $this->sourceContentType;
146 return $this->filePath;
155 return $this->context;
171 private function getMiscPath()
173 return $this->encryptor->hash(
174 implode(
'_', $this->convertToReadableFormat($this->miscParams)),
184 private function getImageInfo()
187 . DIRECTORY_SEPARATOR . $this->getMiscPath()
189 return preg_replace(
'|\Q'. DIRECTORY_SEPARATOR .
'\E+|', DIRECTORY_SEPARATOR,
$path);
197 private function convertToReadableFormat($miscParams)
199 $miscParams[
'image_height'] =
'h:' . ($miscParams[
'image_height'] ??
'empty');
200 $miscParams[
'image_width'] =
'w:' . ($miscParams[
'image_width'] ??
'empty');
201 $miscParams[
'quality'] =
'q:' . ($miscParams[
'quality'] ??
'empty');
202 $miscParams[
'angle'] =
'r:' . ($miscParams[
'angle'] ??
'empty');
203 $miscParams[
'keep_aspect_ratio'] = (isset($miscParams[
'keep_aspect_ratio']) ?
'' :
'non') .
'proportional';
204 $miscParams[
'keep_frame'] = (isset($miscParams[
'keep_frame']) ?
'' :
'no') .
'frame';
205 $miscParams[
'keep_transparency'] = (isset($miscParams[
'keep_transparency']) ?
'' :
'no') .
'transparency';
206 $miscParams[
'constrain_only'] = (isset($miscParams[
'constrain_only']) ?
'do' :
'not') .
'constrainonly';
207 $miscParams[
'background'] = isset($miscParams[
'background'])
208 ?
'rgb' . implode(
',', $miscParams[
'background'])
__construct(ConfigInterface $mediaConfig, ContextInterface $context, EncryptorInterface $encryptor, $filePath, array $miscParams)