5 * Install, update and uninstall functions for the image module.
9 * Implements hook_install().
11 function image_install() {
12 // Create the styles directory and ensure it's writable.
13 $directory = file_default_scheme() . '://styles';
14 file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
18 * Implements hook_uninstall().
20 function image_uninstall() {
21 // Remove the styles directory and generated images.
22 file_unmanaged_delete_recursive(file_default_scheme() . '://styles');
26 * Implements hook_requirements() to check the PHP GD Library.
30 function image_requirements($phase) {
31 if ($phase != 'runtime') {
35 $toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit();
37 $plugin_definition = $toolkit->getPluginDefinition();
40 'title' => t('Image toolkit'),
41 'value' => $toolkit->getPluginId(),
42 'description' => $plugin_definition['title'],
46 foreach ($toolkit->getRequirements() as $key => $requirement) {
47 $namespaced_key = 'image.toolkit.' . $toolkit->getPluginId() . '.' . $key;
48 $requirements[$namespaced_key] = $requirement;
54 'title' => t('Image toolkit'),
56 'description' => t("No image toolkit is configured on the site. Check PHP installed extensions or add a contributed toolkit that doesn't require a PHP extension. Make sure that at least one valid image toolkit is enabled."),
57 'severity' => REQUIREMENT_ERROR,
66 * Flush caches as we changed field formatter metadata.
68 function image_update_8201() {
69 // Empty update to trigger a cache flush.