CodeExplorer writeThumbnail example
try { foreach ($thumbnailSizes as $size) { $thumbnailSize =
$this->
calculateThumbnailSize($originalImageSize,
$size,
$config);
$thumbnail =
$this->
createNewImage($mediaImage,
$type,
$originalImageSize,
$thumbnailSize);
$url =
$this->urlGenerator->
getRelativeThumbnailUrl( $media,
(new MediaThumbnailEntity())->
assign(['width' =>
$size->
getWidth(), 'height' =>
$size->
getHeight()]) );
$this->
writeThumbnail($thumbnail,
$media,
$url,
$config->
getThumbnailQuality());
$mediaFilesystem =
$this->
getFileSystem($media);
if ($originalImageSize ===
$thumbnailSize &&
$mediaFilesystem->
fileSize($originalUrl) <
$mediaFilesystem->
fileSize($url)) { $mediaFilesystem->
write($url,
$mediaFilesystem->
read($originalUrl));
} $savedThumbnails[] =
[ 'mediaId' =>
$media->
getId(),
'width' =>
$size->
getWidth(),
'height' =>
$size->
getHeight(),
];