public function SettingsForm::regenerateThumbnails in Media PDF Thumbnail 8
Same name and namespace in other branches
- 8.2 src/Form/SettingsForm.php \Drupal\media_pdf_thumbnail\Form\SettingsForm::regenerateThumbnails()
RegenerateThumbnails.
File
- src/
Form/ SettingsForm.php, line 61
Class
- SettingsForm
- Class SettingsForm.
Namespace
Drupal\media_pdf_thumbnail\FormCode
public function regenerateThumbnails() {
$res = Drupal::entityTypeManager()
->getStorage('media')
->getQuery()
->condition('bundle', 'file')
->execute();
if ($res) {
$medias = Drupal::entityTypeManager()
->getStorage('media')
->loadMultiple($res);
if ($medias) {
foreach ($medias as $media) {
$media
->save();
}
}
Drupal::messenger()
->addMessage(t('Images have been regenerated'), 'success');
}
}