-
Notifications
You must be signed in to change notification settings - Fork 3
Features
Existing managed files can be converted while editing the containing node.
Manage fields page of a content type. Showing a new file field using the Convert File widget:
Convert File widget exposes two new configuration elements to the field settings:
Display the current converted file, as well as all backups of previous versions.
Configuration:
Display (this file was uploaded as .txt, auto converted to .odt, then later via inline conversion form to .pdf):
While editing the reaction rule "CF Google Drive convert to PDF"
Code may also provide file conversion by calling the following function convertfile_convert_file(), though rules still provide the ultimate functionality.
/**
* Programmatic wrapper for convertfile_validate_conversion().
*
* Call this function directly to perform a programmatically based conversion.
*
* @param int|stdClass $file
* The FID or file object to convert. This object may be modified.
* @param string $provider
* The machine name of the provider.
* @param string $format
* The machine name of the format to convert to.
*
* @return bool
* TRUE on successful conversion, FALSE otherwise. See watchdog for error
* details.
*/
function convertfile_convert_file($file, $provider, $format, $extensions = NULL) {
$report = FALSE;
$file = (is_object($file)) ? $file : file_load($file);
if ($file) {
$instance = array(
'widget' => array(
'settings' => array(
'convertfile_provider' => $provider,
'convertfile_format' => $format,
'convertfile_extensions' => $extensions,
),
),
);
$result = convertfile_validate_conversion($file, $instance);
if (is_array($result) && empty($result)) {
$report = TRUE;
}
}
return $report;
}Any failed conversion happening during an upload will fail the entire upload via validation form errors.