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

related_resource_pull()

Description

Get a related resource to pull images from

Parameters

ColumnTypeDefaultDescription
$resource array Array of resource data from do_search()

Return

array|bool $resdata Array of alternative resource data to use, or false if not configured or no resource image found

Location

include/resource_functions.php lines 9498 to 9531

Definition

 
function related_resource_pull(array $resource)
    {
    global 
$resource_path_pull_cache;
    
$related false;
    if (isset(
$resource_path_pull_cache[$resource["ref"]]))
        {
        return 
$resource_path_pull_cache[$resource["ref"]];
        }

    
$restypes get_resource_types('',false,true,true);
    
$pull_images array_column($restypes,"pull_images","ref")[$resource['resource_type']];
    if ((int)
$pull_images === 1)
        {
        
$relatedpull do_search("!related" $resource["ref"]);
        
debug("Looking for a related resource with image for resource ID #" $resource["ref"]);
        if (
is_array($relatedpull))
            {
            foreach (
$relatedpull as $related)
                {
                if(
$related["has_image"] !== RESOURCE_PREVIEWS_NONE)
                    {
                    
$relatedpath get_resource_path($related["ref"],true,"pre",false,"jpg",true,1,false);
                    if(
file_exists($relatedpath))
                        {
                        
$resource_path_pull_cache[$resource["ref"]] = $related;
                        
debug("Found related resource with image: " $related["ref"]);
                        break;
                        }
                    }
                }
            }
        }
    return 
$related;
    }

This article was last updated 15th December 2024 13:35 Europe/London time based on the source file dated 13th December 2024 14:45 Europe/London time.