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_resource_all_image_sizes()

Description

Return all sizes available for a specific resource. Multi page resources should have each page size included as well
in the output.

Parameters

ColumnTypeDefaultDescription
$ref integer Resource ID

Return

array

Location

include/resource_functions.php lines 7652 to 7720

Definition

 
function get_resource_all_image_sizes($ref)
    {
    if(
get_resource_access($ref) !== 0)
        {
        return array();
        }

    
$resource_data get_resource_data($reftrue);
    if(
$resource_data["file_extension"] == "" || $resource_data["preview_extension"] == "")
        {
        return array();
        }

    
$extensions = array($resource_data["file_extension"], $resource_data["preview_extension"]);
    
$all_image_sizes = array();

    foreach(
$extensions as $extension)
        {
        
$available_sizes_by_extension get_image_sizes($reftrue$extensiontrue);

        foreach(
$available_sizes_by_extension as $size_data)
            {
            
$size_id trim($size_data["id"]) === "" "original" $size_data["id"];

            if(
array_key_exists("{$size_id}_{$size_data["extension"]}"$all_image_sizes))
                {
                continue;
                }

            
$key "{$size_id}_{$size_data["extension"]}";
            
$all_image_sizes[$key]["size_code"] = $size_id;
            
$all_image_sizes[$key]["extension"] = $size_data["extension"];
            
$all_image_sizes[$key]["path"] = $size_data["path"];
            
$all_image_sizes[$key]["url"] = $size_data["url"];
            
$all_image_sizes[$key]["width"] = $size_data["width"];
            
$all_image_sizes[$key]["height"] = $size_data["height"];
            
$all_image_sizes[$key]["filesize"] = $size_data["filesize"];

            
// Screen size can have multi page previews so if this is one of those cases, get rest of the pages before
            // moving on to the next available size
            
if($size_id == "scr" && ($page_count get_page_count($resource_data)) && $page_count 1)
                {
                
// First page is always the normal scr size preview, so just tag it as such.
                
$all_image_sizes[$key]["multi_page"] = true;
                
$all_image_sizes[$key]["page"] = 1;

                for(
$page 2$page <= $page_count$page++)
                    {
                    
$path get_resource_path($reftrue"scr"false$extensiontrue$page);
                    if(!
file_exists($path))
                        {
                        continue;
                        }

                    
$url get_resource_path($reffalse"scr"false$extensiontrue$page);

                    
$key "{$size_id}_{$size_data["extension"]}_{$page}";
                    
$all_image_sizes[$key]["size_code"] = $size_id;
                    
$all_image_sizes[$key]["extension"] = $size_data["extension"];
                    
$all_image_sizes[$key]["multi_page"] = true;
                    
$all_image_sizes[$key]["page"] = $page;
                    
$all_image_sizes[$key]["url"] = $url;
                    }
                }
            }
        }

    return 
array_values($all_image_sizes);
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 15th November 2024 18:30 Europe/London time.