| 7 image.module | image_style_url($style_name, $path) |
| 8 image.module | image_style_url($style_name, $path) |
Return the URL for an image derivative given a style and image path.
Parameters
$style_name: The name of the style to be used with this image.
$path: The path to the image.
Return value
The absolute URL where a style image can be downloaded, suitable for use in an <img> tag. Requesting the URL will cause the image to be created.
See also
9 calls to image_style_url()
File
- modules/
image/ image.module, line 960 - Exposes global functionality for creating image styles.
Code
function image_style_url($style_name, $path) {
$uri = image_style_path($style_name, $path);
// If not using clean URLs, the image derivative callback is only available
// with the query string. If the file does not exist, use url() to ensure
// that it is included. Once the file exists it's fine to fall back to the
// actual file path, this avoids bootstrapping PHP once the files are built.
if (!variable_get('clean_url') && file_uri_scheme($uri) == 'public' && !file_exists($uri)) {
$directory_path = file_stream_wrapper_get_instance_by_uri($uri)->getDirectoryPath();
return url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE));
}
return file_create_url($uri);
}
Login or register to post comments
Comments
$path param is actually a uri
The parameter $path is actually a uri in the form
public://path/to/fileTo get a proper uri you can use file_build_uri() or you can find it in the uri column of the file_managed table.
If you don't use a uri and only use a path (e.g. "path/to/file"), you'll receive a php fatal error: Call to a member function getDirectoryPath() on a non-object
360 Degree Product View
Hi,
I have a requirement in my project for 360 degree view of product Image. I am using Version 6 for drupal. I went through Jquery Reel Formatter module but it is still under development for Drupal 6. Could anyone suggest me a module for the same or could anyone suggest me a solution or a customized module if someone has gone through a similar requirement.
Many thanks in advance,
Dharini
The discussion forum
The discussion forum is over there. Comments here are for sharing information about the PHP functions documented here.
image_style_uri
how can i get image_style_uri?
<?phpstr_replace($base_url.'/sites/default/files/','public://',image_style_url($style,$file->uri));
?>
found this :)
found this :) image_style_path