images styles generation notice fix

This commit is contained in:
Bachir Soussi Chiadmi 2021-03-17 19:21:01 +01:00
parent 8964b94b9f
commit d553146450
1 changed files with 5 additions and 30 deletions

View File

@ -8,41 +8,16 @@ namespace Drupal\images_styles_gen;
class CreateImagesStyles { class CreateImagesStyles {
public static function createStyles($item, &$context){ public static function createStyles($item, &$context){
if (!$context['sandbox']['progress']) {
$context['sandbox']['progress'] = 0;
}
$context['sandbox']['progress']++; $context['sandbox']['progress']++;
$context['sandbox']['current_file'] = $item->uri; $context['sandbox']['current_file'] = $item->uri;
// $message = 'Creating Styles ...'; // $message = 'Creating Styles ...';
$results = array(); $results = array();
// foreach ($items as $item) { $results[] = $item->style->createDerivative($item->uri, $item->destination);
$results[] = $item->style->createDerivative($item->uri, $item->destination);
// }
// $styles_storage = \Drupal::entityTypeManager()->getStorage('image_style');
// $styles = $styles_storage->loadMultiple();
//
// foreach ($fids as $fid) {
// /** @var \Drupal\file\FileInterface|null $file*/
// $file_entity = \Drupal::entityTypeManager()->getStorage('file')->load($fid);
// $file_uri = $file_entity->getFileUri();
// $image = \Drupal::service('image.factory')->get($file_uri);
// // \Drupal::logger('images_styles_gen')->notice("file_uri is $file_uri");
//
// if ($image->isValid()) {
// /** @var \Drupal\image\Entity\ImageStyle $style */
// foreach ($styles as $style) {
// $destination = $style->buildUri($file_uri);
// // if destination exists skip
// if (file_exists($destination)) continue; // skip existing files
//
// $results[] = $style->createDerivative($file_uri, $destination);
// // \Drupal::logger('images_styles_gen')->notice("Generated style $file_uri to $destination");
// }
//
// }
//
//
// }
// $context['message'] = $message;
// $context['results'] = $results;
$context['message'] = $item->uri . ' processed.'; $context['message'] = $item->uri . ' processed.';
$context['results'][] = $item->destination; $context['results'][] = $item->destination;
} }