2009-07-12 08:36:35 +00:00
<?php
/**
* @file
* Install, update and uninstall functions for the image module.
*/
/**
2009-12-04 16:49:48 +00:00
* Implements hook_install().
2009-07-12 08:36:35 +00:00
*/
function image_install() {
// Create the styles directory and ensure it's writable.
2010-09-01 20:08:17 +00:00
$directory = file_default_scheme() . '://styles';
2014-01-24 09:45:47 +00:00
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
2009-07-12 08:36:35 +00:00
}
/**
2009-12-04 16:49:48 +00:00
* Implements hook_uninstall().
2009-07-12 08:36:35 +00:00
*/
function image_uninstall() {
// Remove the styles directory and generated images.
2010-09-01 20:08:17 +00:00
file_unmanaged_delete_recursive(file_default_scheme() . '://styles');
2009-07-12 08:36:35 +00:00
}
2010-04-04 13:18:18 +00:00
/**
* Implements hook_requirements() to check the PHP GD Library.
*
* @param $phase
*/
function image_requirements($phase) {
2014-01-03 12:42:22 +00:00
if ($phase != 'runtime') {
2017-03-04 01:20:24 +00:00
return [];
2014-01-03 12:42:22 +00:00
}
2010-04-04 13:18:18 +00:00
2014-01-03 12:42:22 +00:00
$toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit();
if ($toolkit) {
$plugin_definition = $toolkit->getPluginDefinition();
2017-03-04 01:20:24 +00:00
$requirements = [
'image.toolkit' => [
2014-01-03 12:42:22 +00:00
'title' => t('Image toolkit'),
'value' => $toolkit->getPluginId(),
'description' => $plugin_definition['title'],
2017-03-04 01:20:24 +00:00
],
];
2010-04-04 13:18:18 +00:00
2014-01-03 12:42:22 +00:00
foreach ($toolkit->getRequirements() as $key => $requirement) {
$namespaced_key = 'image.toolkit.' . $toolkit->getPluginId() . '.' . $key;
$requirements[$namespaced_key] = $requirement;
2010-04-04 13:18:18 +00:00
}
2014-01-03 12:42:22 +00:00
}
else {
2017-03-04 01:20:24 +00:00
$requirements = [
'image.toolkit' => [
2014-01-03 12:42:22 +00:00
'title' => t('Image toolkit'),
'value' => t('None'),
'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."),
2010-04-04 13:18:18 +00:00
'severity' => REQUIREMENT_ERROR,
2017-03-04 01:20:24 +00:00
],
];
2010-04-04 13:18:18 +00:00
}
return $requirements;
}
Issue #2421427 by samuel.mortenson, droplet, dawehner, nod_, Cottser, Wim Leers, xjm, Gábor Hojtsy, Bojhan, tstoeckler, webchick, naveenvalecha, alexpott, LewisNyman, chris_h, Manjit.Singh, phenaproxima, avitslv, yoroy, tim.plunkett, Mixologic, ipwa, slashrsm: Improve the UX of Quick Editing single-valued image fields
2016-11-15 20:57:16 +00:00
/**
* Flush caches as we changed field formatter metadata.
*/
function image_update_8201() {
// Empty update to trigger a cache flush.
}