Skip to content

Commit 8f99daa

Browse files
committed
Fix #23 - Keyword settings in publish service settings dialog get cut-off
Fix #21 - bad argument #1 to '?'
1 parent bfc6b35 commit 8f99daa

9 files changed

Lines changed: 223 additions & 103 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
2+
## [20260106.24] - 2026-01-06
3+
### Fixed
4+
Fix #23 - Keyword settings in publish service settings dialog get cut-off
5+
Fix #21 - bad argument #1 to '?' - see readme note on embedded metadata
6+
7+
28
## [20260105.23] - 2026-01-05
39
### Fixed
410
Fix #24 rename album does not update custom metadata. Also fix error that incorrect albumname was used for metadata with special collections

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ A Lightroom Classic plugin which publishes images to a Piwigo host via the Piwig
1515

1616
* Metadata and keywords are exported directly to Piwigo regardless of exif/iptc settings - as part of the publish process along with the photo, or separately via a menu on the Library -> Plug-in Extras menu - which sends the metadata without re-sending the photo.
1717
* the following fields are set :
18-
* author from Lrc Creator,
19-
* date_creation from LrC Date Time Original
18+
* author from LrC Creator,
19+
* date_creation from LrC Created Date, Original Date, Capture Date or Imagefile Creation Date - whichever is found first.
2020
* name (title) - default from LrC Title,
2121
* comment (description) - default from LrC Caption,
2222
* tokenised strings may be used instead for image name (title) and comment (description) - tokens idenfified by {{token}} will be substituted for image specific values on export. All metadata documented in photo:getFormattedMetadata (see https://archive.stecman.co.nz/files/docs/lightroom-sdk/API-Reference/modules/LrPhoto.html#photo:getFormattedMetadata) and photo:getRawMetadata (see https://archive.stecman.co.nz/files/docs/lightroom-sdk/API-Reference/modules/LrPhoto.html#photo:getRawMetadata) from the Lightroom Classic SDK are supported as tokens - for example: title, caption, headline, altTextAccessibility, extDescrAccessibility, copyName will substitute the corresponding values from the image.

piwigoPublish.lrplugin/Info.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ return {
5959

6060
LrPluginInfoProvider = 'PluginInfo.lua',
6161

62-
VERSION = { major=20260105, minor=23, revision=0 },
62+
VERSION = { major=20260106, minor=24, revision=0 },
6363
}

piwigoPublish.lrplugin/Init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ end
7272

7373
_G.PiwigoBusy = false
7474
_G.iconPath = _PLUGIN:resourceId("icons/icon_med.png")
75-
_G.pluginVersion = "20260105.23"
75+
_G.pluginVersion = "20260106.24"
7676
--_G.LocStrings = utils.loadStrings()
7777

piwigoPublish.lrplugin/PWSendMetadata.lua

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,10 @@ local function SendMetadata()
9696
callStatus = {}
9797
local metaData = {}
9898

99-
-- allow custom metadata selection here
100-
if publishSettings.mdTitle and publishSettings.mdTitle ~= "" then
101-
metaData.Title = utils.setCustomMetadata(lrPhoto, publishSettings.mdTitle)
102-
else
103-
metaData.Title = lrPhoto:getFormattedMetadata("title") or ""
104-
end
105-
if publishSettings.mdDescription and publishSettings.mdDescription ~= "" then
106-
metaData.Caption = utils.setCustomMetadata(lrPhoto, publishSettings.mdDescription)
107-
else
108-
metaData.Caption = lrPhoto:getFormattedMetadata("caption") or ""
109-
end
110-
111-
metaData.Creator = lrPhoto:getFormattedMetadata( "creator" ) or ""
112-
113-
metaData.fileName = lrPhoto:getFormattedMetadata("fileName") or ""
114-
local lrTime = lrPhoto:getRawMetadata("dateTimeOriginal")
115-
metaData.dateCreated = LrDate.timeToUserFormat(lrTime, "%Y-%m-%d %H:%M:%S")
99+
-- build metadata structure
100+
metaData = utils.getPhotoMetadata(publishSettings,lrPhoto)
116101
metaData.Remoteid = remoteId
117-
metaData.tagString = utils.BuildTagString(publishSettings, lrPhoto)
102+
118103
callStatus = PiwigoAPI.updateMetadata(publishSettings,lrPhoto,metaData)
119104
if not callStatus.status then
120105
LrDialogs.message("Unable to set metadata for uploaded photo - " .. callStatus.statusMsg)

piwigoPublish.lrplugin/PiwigoAPI.lua

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -926,11 +926,12 @@ end
926926
-- *************************************************
927927
function PiwigoAPI.createPublishCollection(catalog, publishService, propertyTable, name, remoteId, parentSet)
928928
-- create new publish collection or return existing
929-
log:info("createPublishCollection - " .. name .. ", " .. remoteId)
929+
930930
local newColl
931931
catalog:withWriteAccessDo("Create PublishedCollection ", function()
932932
newColl = publishService:createPublishedCollection(name, parentSet, true)
933933
end)
934+
934935
-- add remoteids and urls to collection
935936
PiwigoAPI.setCollectionDets(newColl, catalog, propertyTable, name, remoteId, parentSet)
936937

@@ -950,7 +951,7 @@ function PiwigoAPI.validatePiwigoStructure(propertyTable)
950951
local rv, allCats
951952
local catalog = LrApplication.activeCatalog()
952953
rv = PiwigoAPI.getPublishService(propertyTable)
953-
if not rv then
954+
if not PiwigoAPI.getPublishService(propertyTable) then
954955
LrErrors.throwUserError("Error in validatePiwigoStructure: Cannot find Piwigo publish service for host/user.")
955956
return false
956957
end
@@ -1294,7 +1295,7 @@ function PiwigoAPI.checkAdmin(propertyTable)
12941295
if not (propertyTable.Connected) then
12951296
rv = PiwigoAPI.login(propertyTable)
12961297
if not rv then
1297-
callStatus.statusMsg = 'PiwigoAPI:updateMetadata - cannot connect to piwigo'
1298+
callStatus.statusMsg = 'PiwigoAPI.checkAdmin - cannot connect to piwigo'
12981299
return callStatus
12991300
end
13001301
end
@@ -1756,6 +1757,7 @@ end
17561757

17571758
-- *************************************************
17581759
function PiwigoAPI.checkPhoto(propertyTable, pwImageID)
1760+
log:info("PiwigoAPI.checkPhoto - checking for photo with id " .. pwImageID)
17591761
-- check if image with this id exists on Piwigo
17601762
-- pwg.images.getInfo
17611763
local rtnStatus = {}
@@ -1800,10 +1802,19 @@ function PiwigoAPI.updateGallery(propertyTable, exportFilename, metaData)
18001802
local params = {
18011803
{ name = "method", value = "pwg.images.addSimple" },
18021804
{ name = "category", value = metaData.Albumid },
1803-
{ name = "author", value = metaData.Creator },
1804-
{ name = "name", value = metaData.Title },
1805-
{ name = "comment", value = metaData.Caption }
18061805
}
1806+
if metaData.Title and metaData.Title ~= "" then
1807+
table.insert(params,
1808+
{ name = "name", value = metaData.Title })
1809+
end
1810+
if metaData.Creator and metaData.Creator ~= "" then
1811+
table.insert(params,
1812+
{ name = "author", value = metaData.Creator })
1813+
end
1814+
if metaData.Caption and metaData.Caption ~= "" then
1815+
table.insert(params,
1816+
{ name = "comment", value = metaData.Caption })
1817+
end
18071818
-- keywords
18081819
if metaData.tagString and metaData.tagString ~= "" then
18091820
table.insert(params,
@@ -1935,29 +1946,53 @@ function PiwigoAPI.updateMetadata(propertyTable, lrPhoto, metaData)
19351946
return callStatus
19361947
end
19371948
if metaData.Remoteid ~= "" then
1938-
log:info("PiwigoAPI.updateMetadata - checking for existing photo with remoteid " .. metaData.Remoteid)
1949+
19391950
local rtnStatus = PiwigoAPI.checkPhoto(propertyTable, metaData.Remoteid)
19401951
if not rtnStatus.status then
1952+
log:info("PiwigoAPI.updateMetadata - checking for existing photo with remoteid " .. metaData.Remoteid)
19411953
callStatus.statusMsg = "PiwigoAPI.updateMetadata - cannot locate image " ..
19421954
metaData.Remoteid .. " on Piwigo - cannot update metadata"
19431955
return callStatus
19441956
end
19451957
else
1958+
log:info("PiwigoAPI.updateMetadata - checking for existing photo with remoteid " .. metaData.Remoteid)
19461959
callStatus.statusMsg = "PiwigoAPI.updateMetadata - missing Piwigo image ID - cannot update metadata"
19471960
return callStatus
19481961
end
19491962

1950-
local params = {
1963+
-- sanity check metadata
1964+
metaData.Creator = metaData.Creator or ""
1965+
metaData.Title = metaData.Title or ""
1966+
metaData.Caption = metaData.Caption or ""
1967+
metaData.dateCreated = metaData.dateCreated or ""
1968+
metaData.tagString = metaData.tagString or ""
1969+
-- parameters for POST
1970+
1971+
local params = {
19511972
{ name = "method", value = "pwg.images.setInfo" },
19521973
{ name = "image_id", value = tostring(metaData.Remoteid) },
1953-
{ name = "author", value = metaData.Creator },
1954-
{ name = "name", value = metaData.Title },
1955-
{ name = "comment", value = metaData.Caption },
1956-
{ name = "date_creation", value = metaData.dateCreated },
19571974
{ name = "single_value_mode", value = "replace" }, -- force metadata to be replaced rather than appended
19581975
{ name = "multiple_value_mode", value = "replace" }, -- force tags to be replaced rather than appended
19591976
{ name = "pwg_token", value = propertyTable.token }
19601977
}
1978+
1979+
if metaData.Title and metaData.Title ~= "" then
1980+
table.insert(params,
1981+
{ name = "name", value = metaData.Title })
1982+
end
1983+
if metaData.Creator and metaData.Creator ~= "" then
1984+
table.insert(params,
1985+
{ name = "author", value = metaData.Creator })
1986+
end
1987+
if metaData.dateCreated and metaData.dateCreated ~= "" then
1988+
table.insert(params,
1989+
{ name = "date_creation", value = metaData.dateCreated })
1990+
end
1991+
if metaData.Caption and metaData.Caption ~= "" then
1992+
table.insert(params,
1993+
{ name = "comment", value = metaData.Caption })
1994+
end
1995+
19611996
-- keywords
19621997
if metaData.tagString and metaData.tagString ~= "" then
19631998
-- convert tagString to list of tagIDS
@@ -1985,7 +2020,7 @@ function PiwigoAPI.updateMetadata(propertyTable, lrPhoto, metaData)
19852020
end
19862021
end
19872022

1988-
-- now update Piwigo
2023+
-- now update Piwigo
19892024
local postResponse = PiwigoAPI.httpPostMultiPart(propertyTable, params)
19902025
if not postResponse.status then
19912026
callStatus.statusMsg = "Unable to set metadata - " .. postResponse.statusMsg
@@ -2096,8 +2131,10 @@ function PiwigoAPI.specialCollections(propertyTable)
20962131
local remoteId = thisSet:getRemoteId()
20972132
local name = thisSet:getName()
20982133
local scName = PiwigoAPI.buildSpecialCollectionName(name)
2134+
log:info("Processing collection set " ..
2135+
thisSet:getName() .. ", " .. scName .. ", remoteId " .. tostring(remoteId))
20992136
local scColl = PiwigoAPI.createPublishCollection(catalog, publishService, propertyTable, scName, remoteId,
2100-
thisSet)
2137+
thisSet)
21012138
if scColl == nil then
21022139
LrDialogs.message("Failed to create special collection for " .. name, "", "warning")
21032140
end
@@ -2326,16 +2363,14 @@ function PiwigoAPI.httpPostMultiPart(propertyTable, params)
23262363
-- LrHttp.postMultipart( url, content, headers, timeout, callbackFn, suppressFormData )
23272364
local postResponse = {}
23282365
local postHeaders = {}
2329-
log:info("PiwigoAPI.httpPostMultiPart - params\n" .. utils.serialiseVar(params))
2366+
23302367
local httpResponse, httpHeaders = LrHttp.postMultipart(
23312368
propertyTable.pwurl,
23322369
params,
23332370
{
23342371
headers = { field = "Cookie", value = propertyTable.cookies }
23352372
}
23362373
)
2337-
log:info("PiwigoAPI.httpPostMultiPart - httpResponse \n" .. utils.serialiseVar(httpResponse))
2338-
log:info("PiwigoAPI.httpPostMultiPart - httpHeaders \n" .. utils.serialiseVar(httpHeaders))
23392374

23402375
local body
23412376
if httpResponse then
@@ -2346,6 +2381,9 @@ function PiwigoAPI.httpPostMultiPart(propertyTable, params)
23462381
postHeaders.statusDesc = (httpHeaders and (httpHeaders.statusDes or httpHeaders.statusDesc)) or ""
23472382
end
23482383
if not body then
2384+
log:info("PiwigoAPI.httpPostMultiPart - params\n" .. utils.serialiseVar(params))
2385+
log:info("PiwigoAPI.httpPostMultiPart - httpResponse \n" .. utils.serialiseVar(httpResponse))
2386+
log:info("PiwigoAPI.httpPostMultiPart - httpHeaders \n" .. utils.serialiseVar(httpHeaders))
23492387
postResponse.status = false
23502388
postResponse.statusMsg = postHeaders.status .. " - " .. postHeaders.statusDesc
23512389
return postResponse
@@ -2355,10 +2393,16 @@ function PiwigoAPI.httpPostMultiPart(propertyTable, params)
23552393
postResponse.status = true
23562394
postResponse.statusMsg = ""
23572395
else
2396+
log:info("PiwigoAPI.httpPostMultiPart - params\n" .. utils.serialiseVar(params))
2397+
log:info("PiwigoAPI.httpPostMultiPart - httpResponse \n" .. utils.serialiseVar(httpResponse))
2398+
log:info("PiwigoAPI.httpPostMultiPart - httpHeaders \n" .. utils.serialiseVar(httpHeaders))
23582399
postResponse.status = false
23592400
postResponse.statusMsg = body.message or ""
23602401
end
23612402
else
2403+
log:info("PiwigoAPI.httpPostMultiPart - params\n" .. utils.serialiseVar(params))
2404+
log:info("PiwigoAPI.httpPostMultiPart - httpResponse \n" .. utils.serialiseVar(httpResponse))
2405+
log:info("PiwigoAPI.httpPostMultiPart - httpHeaders \n" .. utils.serialiseVar(httpHeaders))
23622406
postResponse.status = false
23632407
postResponse.statusMsg = body.message or ""
23642408
end

piwigoPublish.lrplugin/PublishDialogSections.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,14 @@ local function prefsDialog(f, propertyTable)
341341
fill_horizontal = 1,
342342
f:spacer { height = 2 },
343343
f:row {
344+
fill_horizontal = 1,
344345
f:static_text {
345346
title = "",
346-
alignment = 'left',
347+
alignment = 'right',
347348
width_in_chars = 7,
348349
},
349350
f:checkbox {
351+
font = "<system>",
350352
title = "Include Full Keyword Hierarchy",
351353
tooltip = "If checked, all keywords in a keyword hierarchy will be sent to Piwigo",
352354
value = bind 'KwFullHierarchy',
@@ -356,12 +358,14 @@ local function prefsDialog(f, propertyTable)
356358
f:spacer { height = 2 },
357359

358360
f:row {
361+
fill_horizontal = 1,
359362
f:static_text {
360363
title = "",
361-
alignment = 'left',
364+
alignment = 'right',
362365
width_in_chars = 7,
363366
},
364367
f:checkbox {
368+
font = "<system>",
365369
title = "Include Keyword Synonyms",
366370
tooltip = "If checked, keyword synonyms will be sent to Piwigo",
367371
value = bind 'KwSynonyms',

0 commit comments

Comments
 (0)