function _image_filename in Image 6
Same name and namespace in other branches
- 5.2 image.module \_image_filename()
- 5 image.module \_image_filename()
- 7 image_legacy.module \_image_filename()
Creates an image filename.
Parameters
$filepath: The full path and filename of the original image file,relative to Drupal root, eg 'sites/default/files/images/myimage.jpg'.
Return value
A full path and filename with derivative image label inserted if required.
3 calls to _image_filename()
- image_create_node_from in ./
image.module - Function to other modules to use to create image nodes.
- _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 892
Code
function _image_filename($filepath, $label = IMAGE_ORIGINAL, $temp = FALSE) {
// Get default path for a new file.
$path = file_directory_path() . '/' . variable_get('image_default_path', 'images');
if ($temp) {
$path .= '/temp';
}
$original_path = dirname($filepath);
$filename = basename($filepath);
if ($label && $label != IMAGE_ORIGINAL) {
// Keep resized images in the same path, where original is (does not
// apply to temporary files, these still use the default path).
if (!$temp && $original_path != '.') {
$path = $original_path;
}
// Insert the resized name in non-original images.
$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);
}