Collections functions
Encryption functions
General functions
Theme permission 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 3445 to 3527

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$prefix_resource_id_to_filename$prefix_filename_string,
           
$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']))
        {
        if(
strtolower($pathparts['extension']) == $pextension)
            {
            
$pextension $pathparts['extension'];
            }
        }

    if (
$usesize!=""&&!$subbed_original){$append="-".$usesize;}else {$append="";}
    
$basename_minus_extension=remove_extension($pathparts['basename']);

    
$fs=explode("/",$filename);$filename=$fs[count($fs)-1];

  
    
    
// check if a file has already been processed with this name
    
if(in_array($filename$filenames))
        {
        
$path_parts pathinfo($filename);
        if(isset(
$path_parts['extension']) && isset($path_parts['filename']))
            {
            
$filename_ext $path_parts['extension'];
            
$filename_wo  $path_parts['filename'];

            
// Run through function to guarantee unique filename
            
$filename makeFilenameUnique($filenames$filename_wo$lang["_dupe"], $filename_ext);
            }
        }
    
    
// Add the filename to the array so it can be checked in the next loop
    
$filenames[] = $filename;

    
# 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=$prefix_filename_string $ref "_" $size "." $pextension;
        }

    return;
    }

This article was last updated 15th July 2020 06:35 Europe/London time based on the source file dated 14th July 2020 15:34 Europe/London time.