Browse Source

images styles generation notice fix

bach 3 years ago
parent
commit
d553146450
1 changed files with 5 additions and 30 deletions
  1. 5 30
      web/modules/custom/images_styles_gen/src/CreateImagesStyles.php

+ 5 - 30
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;
   }