You are here

function ctools_stylizer_get_image_path in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/stylizer.inc \ctools_stylizer_get_image_path()

Get the path where images will be stored for a given style plugin and settings.

This function will make sure the path exists.

3 calls to ctools_stylizer_get_image_path()
ctools_stylizer_add_css in includes/stylizer.inc
Add the necessary CSS for a stylizer plugin to the page.
ctools_stylizer_build_style in includes/stylizer.inc
Build the files for a stylizer given the proper settings.
ctools_stylizer_cleanup_style in includes/stylizer.inc
Clean up no longer used files.

File

includes/stylizer.inc, line 208
Create customized CSS and images from palettes created by user input.

Code

function ctools_stylizer_get_image_path($plugin, $settings, $check = TRUE) {
  $file = 'ctools/style/' . $settings['name'] . '/' . md5(serialize($settings['palette']));
  $path = file_create_path($file);
  if ($check && !ctools_file_check_directory($path)) {
    $base = '';
    foreach (explode('/', $file) as $bit) {
      $base .= '/' . $bit;
      $path = file_directory_path() . $base;
      if (!ctools_file_check_directory($path, FILE_CREATE_DIRECTORY)) {
        drupal_set_message(t('Unable to create CTools styles cache directory @path. Check the permissions on your files directory.', array(
          '@path' => $path,
        )), 'error');
        return;
      }
    }
  }
  return $path;
}