Render the field.
$values: The values retrieved from the database.
Overrides FieldPluginBase::render
function render($values) {
$value = $this
->getValue($values);
if (!$this->options['extension_detect_tar']) {
if (preg_match('/\\.([^\\.]+)$/', $value, $match)) {
return $this
->sanitizeValue($match[1]);
}
}
else {
$file_parts = explode('.', basename($value));
// If there is an extension.
if (count($file_parts) > 1) {
$extension = array_pop($file_parts);
$last_part_in_name = array_pop($file_parts);
if ($last_part_in_name === 'tar') {
$extension = 'tar.' . $extension;
}
return $this
->sanitizeValue($extension);
}
}
}