diff --git a/web/modules/custom/images_styles_gen/src/CreateImagesStyles.php b/web/modules/custom/images_styles_gen/src/CreateImagesStyles.php index 68fdcc2..4703553 100644 --- a/web/modules/custom/images_styles_gen/src/CreateImagesStyles.php +++ b/web/modules/custom/images_styles_gen/src/CreateImagesStyles.php @@ -8,41 +8,16 @@ namespace Drupal\images_styles_gen; class CreateImagesStyles { public static function createStyles($item, &$context){ + if (!$context['sandbox']['progress']) { + $context['sandbox']['progress'] = 0; + } $context['sandbox']['progress']++; $context['sandbox']['current_file'] = $item->uri; // $message = 'Creating Styles ...'; $results = array(); - // foreach ($items as $item) { - $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; + $results[] = $item->style->createDerivative($item->uri, $item->destination); + $context['message'] = $item->uri . ' processed.'; $context['results'][] = $item->destination; }