You are here

function _image_filename in Image 5.2

Same name and namespace in other branches
  1. 5 image.module \_image_filename()
  2. 6 image.module \_image_filename()
  3. 7 image_legacy.module \_image_filename()

Creates an image filename.

4 calls to _image_filename()
image_create_node_from in ./image.module
Function to other modules to use to create image nodes.
image_prepare in ./image.module
Implementation of hook_prepare().
_image_build_derivatives in ./image.module
Generate image derivatives.
_image_insert in ./image.module
Moves temporary (working) images to the final directory and stores relevant information in the files table

File

./image.module, line 1045

Code

function _image_filename($filename, $label = IMAGE_ORIGINAL, $temp = FALSE) {
  $path = file_directory_path() . '/' . variable_get('image_default_path', 'images');
  if ($temp) {
    $path .= '/temp';
  }
  $filename = basename($filename);

  // Insert the resized name in non-original images
  if ($label && $label != IMAGE_ORIGINAL) {
    $pos = strrpos($filename, '.');
    if ($pos === false) {

      // The file had no extension - which happens in really old image.module
      // versions, so figure out the extension.
      $image_info = image_get_info(file_create_path($path . '/' . $filename));
      $filename = $filename . '.' . $label . '.' . $image_info['extension'];
    }
    else {
      $filename = substr($filename, 0, $pos) . '.' . $label . substr($filename, $pos);
    }
  }
  return file_create_path($path . '/' . $filename);
}