To solve the problem I used the code below to force Drupal to create the image styles for my nodes:
if ($entity->hasField('field_image') && $entity->get('field_image')->getValue() != null) {
$image = \Drupal::service('image.factory')->get($entity->get('field_image')->entity->getFileUri());
if ($image->isValid()) {
$styles = \Drupal::entityTypeManager()->getStorage('image_style')->loadMultiple();
$image_uri = $entity->get('field_image')->entity->getFileUri();
foreach ($styles as $style) {
$destination = $style->buildUri($image_uri);
$style->createDerivative($image_uri, $destination);
}
}
}
Here is the description, for each node ($entity variable) , first it checks if the node type has a field with machine name "field_image" and if this field has a value, then it checks if fileUri is a valid image, then if all conditions met, the code iterates on all image styles available and build that style for given image manually.
This code can be used as a cron job function, so on every cron job image styles of given nodes are created.