protected function MediaPdfThumbnailImagickManager::moveImageToThumbnailFolder in Media PDF Thumbnail 8
Move thumbnail image file to thumbnail folder.
Parameters
string $filePath: File path.
Return value
string|null File image path.
1 call to MediaPdfThumbnailImagickManager::moveImageToThumbnailFolder()
- MediaPdfThumbnailImagickManager::generateImage in src/
Manager/ MediaPdfThumbnailImagickManager.php - Generate image from PDF file.
File
- src/
Manager/ MediaPdfThumbnailImagickManager.php, line 51
Class
- MediaPdfThumbnailImagickManager
- Class MediaPdfThumbnailImagickManager.
Namespace
Drupal\media_pdf_thumbnail\ManagerCode
protected function moveImageToThumbnailFolder($filePath) {
if (file_exists($filePath)) {
$filePathArray = explode('/', $filePath);
if (!empty($filePathArray)) {
$parentFolder = $filePathArray[count($filePathArray) - 2];
$fileName = $filePathArray[count($filePathArray) - 1];
if ($parentFolder) {
$destination = 'public://styles/thumbnail/public/' . $parentFolder . '/';
if (file_prepare_directory($destination, FILE_CREATE_DIRECTORY)) {
if (file_unmanaged_move($filePath, $destination, FILE_EXISTS_REPLACE)) {
return $destination . $fileName;
}
}
}
}
}
return NULL;
}