Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

collection_download_use_original_filenames_when_downloading()

Parameters

ColumnTypeDefaultDescription
&$filename
$ref
$collection_download_tar
&$filenames
$id ''

Location

include/collections_functions.php lines 4687 to 4746

Definition

 
function collection_download_use_original_filenames_when_downloading(&$filename$ref$collection_download_tar, &$filenames,$id='')
    {
    if(
trim($filename) === '')
        {
        return;
        }

    global 
$pextension$usesize$subbed_original,
           
$download_filename_id_only$deletion_array$use_zip_extension$copy$exiftool_write_option$p$size$lang;

    
# Only perform the copy if an original filename is set.

    # now you've got original filename, but it may have an extension in a different letter case. 
    # The system needs to replace the extension to change it to jpg if necessary, but if the original file
    # is being downloaded, and it originally used a different case, then it should not come from the file_extension, 
    # but rather from the original filename itself.
    
    # do an extra check to see if the original filename might have uppercase extension that can be preserved.   
    # also, set extension to "" if the original filename didn't have an extension (exiftool identification of filetypes)
    
$pathparts pathinfo($filename);
    if (
        isset(
$pathparts['extension'])
        && 
strtolower($pathparts['extension']) == $pextension
        
) {
            
$pextension $pathparts['extension'];
        }

    
$fs=explode("/",$filename);
    
$filename=$fs[count($fs)-1]; 
    
set_unique_filename($filename,$filenames);
   
    
# Copy to tmp (if exiftool failed) or rename this file
    # this is for extra efficiency to reduce copying and disk usage
    
    
if(!($collection_download_tar || $use_zip_extension))
        {
        
// the copy or rename to the filename is not necessary using the zip extension since the archived filename can be specified.
        
$newpath get_temp_dir(false,$id) . '/' $filename;

        if(!
$copy && $exiftool_write_option)
            {
            
rename($p$newpath);
            }
        else
            {
            
copy($p,$newpath);
            }

        
# Add the temporary file to the post-archiving deletion list.
        
$deletion_array[] = $newpath;

        
# Set p so now we are working with this new file
        
$p $newpath;
        }

    if(empty(
$filename))
        {
        
$filename get_download_filename($ref$size0$pextension);
        }
    }

This article was last updated 19th March 2024 09:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.