pdf_to_image.install in PDF to ImageField 7.3
Same filename and directory in other branches
PDF to Image install and enable hooks.
I make use of imagemagick_convert variable, but do not delete it on uninstall, as this var is actually owned by imagemagick module if it exists.
File
pdf_to_image.installView source
<?php
/**
* @file
* PDF to Image install and enable hooks.
*
* I make use of imagemagick_convert variable, but do not delete it on
* uninstall, as this var is actually owned by imagemagick module if it exists.
*/
/**
* Implements hook_install().
*/
function pdf_to_image_install() {
if ('' == variable_get('imagemagick_convert', '')) {
// Try to find the ImageMagick path.
foreach (array(
'/usr/bin/convert',
'/usr/local/bin/convert',
) as $path) {
if (file_exists($path)) {
variable_set('imagemagick_convert', $path);
break;
}
}
}
}
/**
* Implements hook_requirements().
*/
function pdf_to_image_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time.
$t = get_t();
if ($phase == 'runtime') {
if ($response = pdf_to_image_check_imagemagick()) {
$requirements['pdf_to_image_check_imagemagick'] = array(
'title' => $t('Imagemagick support for PDF to Image'),
'value' => $response,
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['pdf_to_image_check_imagemagick'] = array(
'title' => $t('Imagemagick support for PDF to Image'),
'description' => $t('Imagemagick must be installed and the <a href="!admin_path">path on the server set</a> for PDFs to be processed.', array(
'!admin_path' => url('admin/config/media/image-toolkit'),
)),
'value' => $t("Imagemagick doesn't seem to be available at %path.", array(
'%path' => variable_get('imagemagick_convert', '/usr/bin/convert'),
)),
'severity' => REQUIREMENT_WARNING,
);
}
}
return $requirements;
}
Functions
Name | Description |
---|---|
pdf_to_image_install | Implements hook_install(). |
pdf_to_image_requirements | Implements hook_requirements(). |