function media_entity_copy_icons in Media entity 8
Copy the media file icons to files directory for use with image styles.
Parameters
string $source: Source folder.
string $destination: Destination folder.
Throws
Exception
1 call to media_entity_copy_icons()
- media_entity_install in ./
media_entity.install - Implements hook_install().
File
- ./
media_entity.module, line 72 - Provides media entities.
Code
function media_entity_copy_icons($source, $destination) {
if (!file_prepare_directory($destination, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
throw new Exception("Unable to create directory {$destination}.");
}
$files = file_scan_directory($source, '/.*\\.(png|jpg)$/');
foreach ($files as $file) {
$result = file_unmanaged_copy($file->uri, $destination, FILE_EXISTS_REPLACE);
if (!$result) {
throw new Exception("Unable to copy {$file->uri} to {$destination}.");
}
}
}