Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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


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 6974 to 7012

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 4th December 2024 08:35 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.