File CustomMetadata.lua

Functions

CustomMetadata:clear (photos, call, noThrow) Clear custom metadata for specified photos.
CustomMetadata:getMetadata (photo, pluginId, cMeta) Consolidate custom metadata for specified plugin into a lookup table (dictionary) form.
CustomMetadata:getMetadataSpecs (reread) Gets an array of custom metadata specs, from Metadata.lua
CustomMetadata:getPluginId (name, reverseDomain) Get specific plugin ID, given it's exact (albeit case insensitive) name suffix (must be enabled and have custom metadata).
CustomMetadata:getPluginIds () Get set of plugin Ids (that are enabled and have custom metadata).
CustomMetadata:manualSync () Copy selected metadata values from most selected photo to the other selected photos.
CustomMetadata:migrate (photos, matchFunc) Migrate metadata from previous instance of plugin.
CustomMetadata:new (t) Constructor for new instance.
CustomMetadata:newClass (t) Constructor for extending class.
CustomMetadata:read () Read (all) custom metadata for specified photos, from disk.
CustomMetadata:save () Save (all) custom metadata for specified photos, to disk.
CustomMetadata:update (photo, name, value, version, noThrow, tries) Set custom metadata property of photo to specified value, if not already set to it.


Functions

CustomMetadata:clear (photos, call, noThrow)
Clear custom metadata for specified photos.

Parameters:

  • photos:
  • call:
  • noThrow:
CustomMetadata:getMetadata (photo, pluginId, cMeta)
Consolidate custom metadata for specified plugin into a lookup table (dictionary) form.

Parameters:

  • photo: (LrPhoto, required) photo
  • pluginId: (string, required) plugin id.
  • cMeta: - (table, optional) batch of raw metadata including custom metadata for all plugins.

Return value:

    table - id/value members, or empty - never nil.
CustomMetadata:getMetadataSpecs (reread)
Gets an array of custom metadata specs, from Metadata.lua

Parameters:

  • reread: (boolean, default=false) force re-read.

Usage:

    Initialized upon first use, or a forced re-read..
    (maybe should have made whole provider return-table available, oh well - not needed yet.
CustomMetadata:getPluginId (name, reverseDomain)
Get specific plugin ID, given it's exact (albeit case insensitive) name suffix (must be enabled and have custom metadata).

Parameters:

  • name:
  • reverseDomain:

Usage:

    pluginId, errm = custMeta:getPluginId( "ChangeManager" ) -- for example. 
CustomMetadata:getPluginIds ()
Get set of plugin Ids (that are enabled and have custom metadata).

Usage:

    for id, _ in pairs( custMeta:getPlugIds() ) do -- returns empty but never nil. 
CustomMetadata:manualSync ()
Copy selected metadata values from most selected photo to the other selected photos.
CustomMetadata:migrate (photos, matchFunc)
Migrate metadata from previous instance of plugin.

Parameters:

  • photos:
  • matchFunc: (function, optional) if not passed, will match first two parts of present plugin, and last part.
    if passed, is function that takes a plugin ID and returns true if it matches such that metadata should be transferred.

Usage:

    Throws error if >1 matching plugin. 
CustomMetadata:new (t)
Constructor for new instance.

Parameters:

  • t:
CustomMetadata:newClass (t)
Constructor for extending class.

Parameters:

  • t:
CustomMetadata:read ()
Read (all) custom metadata for specified photos, from disk.

Usage:

  • includes user prompt and the whole nine yards.
  • presently expects files in sibling directory of catalog (named plugin-id), prefixed by photo path. 

Return values:

  1. status (boolean) true if operation completed without uncaught error - there may have been individual file errors logged.
  2. message (string) error message if status false.
CustomMetadata:save ()
Save (all) custom metadata for specified photos, to disk.

Usage:

  • includes user prompt and the whole nine yards.
  • presently saves in sibling directory of catalog (named plugin-id), prefixed by photo path. 

Return values:

  1. status (boolean) true if operation completed without uncaught error - there may have been individual file errors logged.
  2. message (string) error message if status false.
CustomMetadata:update (photo, name, value, version, noThrow, tries)
Set custom metadata property of photo to specified value, if not already set to it.

Parameters:

  • photo: (lr-photo, required) photo set metadata on.
  • name: (string, required) property name
  • value: (string | date | number | boolean, required) property value
  • version: (number, default nil) optional version number.
  • noThrow: (boolean, default false) optional no-throw, if omitted, errors are thrown.
  • tries: (number, default 10) number of tries - only applies if internal catalog wrapping required.

Usage:

  • Will wrap with catalog access if need be.
  • Always throws errors for catastrophic failure, just not for undeclared metadata if no-throw. 

Return values:

  1. status (boolean or nil) true iff property set to different value, false iff property need not be set - already same value, nil => error setting property.
  2. error-message or previous value (string, nil, or any) nil if status false, error message if status nil, previous value if status true.

Valid XHTML 1.0!