Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_video_snapshots()

Description

Check whether a resource (of a video type) has any snapshots created.
Snapshots are being created using config option $ffmpeg_snapshot_frames


@global array $get_resource_path_extra_download_query_string_params Array of query string params
as expected by generateURL()

Parameters

ColumnTypeDefaultDescription
$resource_id integer Resource unique ref
$file_path boolean false Specify whether the return value should be the file path. Default is FALSE
$count_only boolean false Set to true if we are only interested in how many snapshots we have. Default is FALSE
$includemodified false

Return

array|integer Array of all file paths found or number of files found

Location

include/resource_functions.php lines 6267 to 6305

Definition

 
function get_video_snapshots($resource_id$file_path false$count_only false$includemodified false)
    {
    global 
$get_resource_path_extra_download_query_string_params$hide_real_filepath;

    
$snapshots_found = array();
 
    
$template_path            get_resource_path($resource_idtrue,  'snapshot'false'jpg', -11false'');
    
$template_webpath         get_resource_path($resource_idfalse'snapshot'false'jpg', -11false'');

    
$i 1;
    do 
        {
        
$path=str_replace("snapshot","snapshot_" $i,$template_path);
        if(
$hide_real_filepath)
            {
            
$webpath=$template_webpath "&snapshot_frame=" $i;
            }
        else
            {
            
$webpath=str_replace("snapshot","snapshot_" $i,$template_webpath);
            if (
$includemodified && file_exists($path))
                {
                
$webpath .= "?v=" urlencode(filemtime($path));
                }
            }

        
$snapshot_found  file_exists($path);

        if(
$snapshot_found)
            {
            
$snapshots_found[$i] = ($file_path $path $webpath);
            }

        
$i++;
        }
    while (
true === $snapshot_found);

    return (!
$count_only $snapshots_found count($snapshots_found));
    }

This article was last updated 29th May 2022 05:35 Europe/London time based on the source file dated 24th May 2022 09:25 Europe/London time.