public static function PhotosUpload::rename in Album Photos 8.4
Rename file with random name.
3 calls to PhotosUpload::rename()
- PhotosUpload::moveImageFiles in src/
PhotosUpload.php - Assist batch operation by moving or copying image files to album.
- PhotosUpload::unzip in src/
PhotosUpload.php - Unzip archive of image files.
- PhotosUploadForm::submitForm in src/
Form/ PhotosUploadForm.php - Form submission handler.
File
- src/
PhotosUpload.php, line 18
Class
- PhotosUpload
- Functions to help with uploading images to albums.
Namespace
Drupal\photosCode
public static function rename($name = 0, $ext = 0) {
// @todo use transliterate? Or add more options.
if (\Drupal::config('photos.settings')
->get('photos_rname')) {
if ($name) {
$name_parts = explode('.', $name);
return round(rand(15770, 967049700)) . \Drupal::time()
->getRequestTime() . '.' . ($ext ? $ext : end($name_parts));
}
if (!empty($_FILES['files'])) {
foreach ($_FILES['files']['name'] as $field => $filename) {
$filename_parts = explode('.', $filename);
$_FILES['files']['name'][$field] = round(rand(15770, 967049700)) . \Drupal::time()
->getRequestTime() . '.' . ($ext ? $ext : end($filename_parts));
}
}
}
elseif ($name) {
return $name;
}
}