function node_gallery_install_imagecache_presets in Node Gallery 6.3
3 calls to node_gallery_install_imagecache_presets()
- node_gallery_install in ./
node_gallery.install - Implements hook_install()
- node_gallery_update_6100 in ./
node_gallery.install - Implements hook_update_N() Directly installing the default imagecache presets
- node_gallery_update_6300 in ./
node_gallery.install - MAJOR UPGRADE - please don't blindly update from 2.x to 3.x! Your data will migrate, but some of your settings and most of your theming will need to be redone.
File
- ./
node_gallery.install, line 386 - Install, update and uninstall functions for the node_gallery module.
Code
function node_gallery_install_imagecache_presets() {
// First, build an array of all the preset names so we do not make duplicates
// Set the argument to TRUE to reset the cache
$presets = imagecache_presets(TRUE);
$preset_names = array();
// If there are any presets
if ($presets != '') {
foreach ($presets as $preset) {
$preset_names[] = $preset['presetname'];
}
}
// Prepare to install ImageCache presets
$imagecache_presets = array();
$imagecache_actions = array();
// We are checking to make sure the preset name does not exist before creating
if (!in_array('node-gallery-thumbnail', $preset_names)) {
$imagecache_presets[] = array(
'presetname' => 'node-gallery-thumbnail',
);
$imagecache_actions['node-gallery-thumbnail'][] = array(
'action' => 'imagecache_scale_and_crop',
'data' => array(
'width' => 100,
'height' => 100,
),
'weight' => 0,
);
}
if (!in_array('node-gallery-cover', $preset_names)) {
$imagecache_presets[] = array(
'presetname' => 'node-gallery-cover',
);
$imagecache_actions['node-gallery-cover'][] = array(
'action' => 'imagecache_scale_and_crop',
'data' => array(
'width' => 150,
'height' => 150,
),
'weight' => 0,
);
}
if (!in_array('node-gallery-display', $preset_names)) {
$imagecache_presets[] = array(
'presetname' => 'node-gallery-display',
);
$imagecache_actions['node-gallery-display'][] = array(
'action' => 'imagecache_scale',
'data' => array(
'height' => 1500,
),
'weight' => 0,
);
$imagecache_actions['node-gallery-display'][] = array(
'action' => 'imagecache_scale',
'data' => array(
'width' => 600,
),
'weight' => 1,
);
}
if (!in_array('node-gallery-admin-thumbnail', $preset_names)) {
$imagecache_presets[] = array(
'presetname' => 'node-gallery-admin-thumbnail',
);
$imagecache_actions['node-gallery-admin-thumbnail'][] = array(
'action' => 'imagecache_scale_and_crop',
'data' => array(
'width' => 50,
'height' => 50,
),
'weight' => 0,
);
}
// Need to install preset, id will be returned by function,
// Then install action add presetid to action prior to install:
foreach ($imagecache_presets as $preset) {
$preset = imagecache_preset_save($preset);
foreach ($imagecache_actions[$preset['presetname']] as $action) {
$action['presetid'] = $preset['presetid'];
imagecache_action_save($action);
}
drupal_set_message(t('ImageCache preset %id: %name and corresponding actions saved.', array(
'%id' => $preset['presetid'],
'%name' => $preset['presetname'],
)));
}
}