Documentation

clip_functions.php

Table of Contents

Functions

get_vector()  : array<string|int, mixed>|false
Sends an image file or text input to the CLIP vector service and returns the resulting vector.
vector_visualise()  : string
Generates a simple visual representation of a CLIP vector as a 64-character string. This helps visualise differences between vectors in a human-readable form.
clip_generate_vector()  : bool
Generates and stores a CLIP vector for a given resource.
clip_tag()  : bool
Auto-tags and titles a resource using CLIP vector search.
clip_generate_missing_vectors()  : mixed
clip_count_vectors()  : int
Returns a count of vectors in the system
clip_missing_vectors()  : int
Returns a count of vectors missing
clip_vector_cleanup()  : void
Removes orphaned vectors - those that do not have a valid resource specified either because the resource has been removed or because the list of resource types for which vectors are created has been changed.

Functions

get_vector()

Sends an image file or text input to the CLIP vector service and returns the resulting vector.

get_vector(bool $is_text, string $input, int $ref) : array<string|int, mixed>|false
Parameters
$is_text : bool

Whether the input is text (true) or an image file (false).

$input : string

Either the text string or the path to the image file.

$ref : int

The resource ID (used for logging/debugging purposes only).

Return values
array<string|int, mixed>|false

Returns a 512-float array representing the CLIP vector, or false if the service failed or returned invalid data.

vector_visualise()

Generates a simple visual representation of a CLIP vector as a 64-character string. This helps visualise differences between vectors in a human-readable form.

vector_visualise(array<string|int, mixed> $vector) : string
Parameters
$vector : array<string|int, mixed>

A 512-element array of float values (normalised CLIP vector).

Return values
string

A 64-character string "fingerprint" visualising the vector content.

clip_generate_vector()

Generates and stores a CLIP vector for a given resource.

clip_generate_vector(int $ref) : bool

This function:

  • Loads the specified resource data.
  • Attempts to locate a resized (pre) version of the resource image.
  • Sends the image to the CLIP service to obtain a 512-float vector.
  • Stores the resulting vector as a binary blob in the database.
Parameters
$ref : int

The resource ID for which to generate the vector.

Return values
bool

Returns true on success, or false on failure (e.g., file missing or vector generation error).

clip_tag()

Auto-tags and titles a resource using CLIP vector search.

clip_tag(int $resource) : bool

This function sends the resource ID to the external CLIP-based Python service to retrieve suggested keywords and a title based on the resource's content.

It populates:

  • A keyword metadata field (multiple nodes created)
  • A title metadata field (single text string)

Global configuration variables (all available on the plugin's setup page)

  • $clip_service_url: Base URL for the CLIP service
  • $mysql_db: Current MySQL database name
  • $clip_keyword_field: Field ID for keywords (node-based)
  • $clip_keyword_url: URL of tag database for keywords
  • $clip_keyword_count: Number of keyword suggestions to fetch
  • $clip_title_field: Field ID for title (text field)
  • $clip_title_url: URL of tag database for titles
Parameters
$resource : int

Resource ID to tag and title.

Return values
bool

Always returns true after processing.

clip_generate_missing_vectors()

clip_generate_missing_vectors(mixed $limit) : mixed
Parameters
$limit : mixed

clip_count_vectors()

Returns a count of vectors in the system

clip_count_vectors() : int
Return values
int

The total

clip_missing_vectors()

Returns a count of vectors missing

clip_missing_vectors() : int
Return values
int

The total

clip_vector_cleanup()

Removes orphaned vectors - those that do not have a valid resource specified either because the resource has been removed or because the list of resource types for which vectors are created has been changed.

clip_vector_cleanup() : void
On this page

Search results