You are here

function file_styles_preview_image in Styles 7.2

Return the path to the image for previews in Styles UI.

If it doesn't yet exist, then copy the source to the files directory.

Parameters

boolean $replace: If TRUE, then replace the file.

Return value

mixed The path to the image preview file, or FALSE if unable to copy.

1 call to file_styles_preview_image()
theme_file_styles_image_preview in contrib/file_styles/includes/themes/file_styles.theme.inc
Preview image for Styles UI.

File

contrib/file_styles/file_styles.module, line 91
styles/contrib/file_styles/file_styles.module File widget formatter definitions.

Code

function file_styles_preview_image($replace = FALSE) {
  $path = file_styles_variable_get('preview_image');
  if (!$path || $replace) {
    $dir = file_default_scheme() . '://' . file_styles_variable_get('preview_image_directory');
    if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
      $source = file_styles_variable_get('image_style_preview_image');
      if ($path = file_unmanaged_copy($source, $dir . '/' . basename($source), FILE_EXISTS_REPLACE)) {
        file_styles_variable_set('preview_image', $path);
      }
    }
  }
  return $path;
}