1

I am importing many many images (300,000+). This number includes adding different crops for each image.

I might be wrong, but it seems that to get Drupal to know that a crop style has been set, I need to load the crop style and then create an image derivative. Without creating a derivative, the crop will be set for a media item initially, but on cache flush the crop is lost (even though the physical file still exists)

$hero_crop = ImageStyle::load('hero');
$hero_crop->createDerivative($file->getFileUri(), "s3://$stylePath");

I should highlight that we are using the S3FS module to connect and store the images in S3 and I am really hoping that isn't the cause.

However, this takes forever while importing my images. So much so that if my batch script is set to process more than 1 at a time it will still timeout. That means that importing one image takes 15-30 seconds which means the import will take on average 1250 hours to complete.

:/

So my question is, is there an alternative way of creating crop styles or does it need to be done with an image derivative?

7
  • the crop will be set for a media item initially, but on cache flush the crop is lost not quite sure what you mean by this, but image derivatives are generated on request. I don't think they necessarily need to be migrated, because the application will generate it if its not there. – Kevin Feb 4 '19 at 16:57
  • Having said that, I am not familiar with the s3 module (though I know what it is) so I am not sure what might be getting lost in translation there. – Kevin Feb 4 '19 at 17:02
  • The crops have already been set in the previous system which is not Drupal. I there for don't have access to the exact dimensions to give to the crop API to tell it where to crop. I am trying to upload the existing cropped image and tell Drupal to serve that file when requesting the hero crop. Without creating a derivative of that image, Drupal will serve the original file after a cache flush. – Jimmyb_1991 Feb 4 '19 at 17:04
  • Ah, well, that certainly makes it a challenge. – Kevin Feb 4 '19 at 17:04
  • You're going to have to code your own system for that. Drupal Image Styles do not work this way, and you are diverging far enough from what they do do, that I don't see value in trying to override that API to do what you want. – Jaypan Feb 4 '19 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.