image.install

Same filename and directory in other branches
  1. 7.x modules/image/image.install
  2. 9 core/modules/image/image.install
  3. 8.9.x core/modules/image/image.install
  4. 10 core/modules/image/image.install

Install, update and uninstall functions for the image module.

File

core/modules/image/image.install

View source
<?php


/**
 * @file
 * Install, update and uninstall functions for the image module.
 */

use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;

/**
 * Implements hook_install().
 */
function image_install() : void {
  // Create the styles directory and ensure it's writable.
  $directory = \Drupal::config('system.file')->get('default_scheme') . '://styles';
  \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}

/**
 * Implements hook_uninstall().
 */
function image_uninstall() : void {
  // Remove the styles directory and generated images.
  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
  $file_system = \Drupal::service('file_system');
  try {
    $file_system->deleteRecursive(\Drupal::config('system.file')->get('default_scheme') . '://styles');
  } catch (FileException) {
    // Ignore failed deletes.
  }
}

/**
 * Implements hook_update_last_removed().
 */
function image_update_last_removed() : int {
  return 8201;
}

Functions

Title Deprecated Summary
image_install Implements hook_install().
image_uninstall Implements hook_uninstall().
image_update_last_removed Implements hook_update_last_removed().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.