1 views_handler_field_file_uri.inc | views_handler_field_file_uri::render($values) |
Render the field.
Parameters
$values: The values retrieved from the database.
Overrides views_handler_field_file::render
File
- core/
modules/ file/ views/ views_handler_field_file_uri.inc, line 40 - Definition of views_handler_field_file_uri.
Class
- views_handler_field_file_uri
- Field handler to add rendering file paths as file URLs instead of as internal file URIs.
Code
function render($values) {
$data = $values->{$this->field_alias};
if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') {
$data = file_create_url($data);
if (!image_is_svg($data) && !empty($this->options['image_style'])) {
// $data contains url of image.
// Get public file system path and its length.
$file_public_path = '/' . config_get('system.core', 'file_public_path');
$file_public_path_strlen = strlen($file_public_path);
// Find insertion position of public file system path.
$insert_at = strpos($data, $file_public_path);
// Text to insert in order to modify url.
$add_to_url = '/styles/' . $this->options['image_style'] . '/public';
$data = substr_replace($data, $add_to_url, $insert_at + $file_public_path_strlen, 0);
}
}
return $this->render_link($data, $values);
}