Skip to content

Commit 37baf60

Browse files
committed
Fix #27 Album formatting lost on import to LrC
1 parent 8f99daa commit 37baf60

8 files changed

Lines changed: 90 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## [20260106.25] - 2026-01-06
3+
### Fixed
4+
Fix #27 - Album formatting lost on import to LrC
5+
26
## [20260106.24] - 2026-01-06
37
### Fixed
48
Fix #23 - Keyword settings in publish service settings dialog get cut-off

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ A Lightroom Classic plugin which publishes images to a Piwigo host via the Piwig
1111
* Special collections can be created which allow images to be published to Piwigo albums that also have sub-albums. See details in the notes on the relationship between Piwigo Albums and LrC Publish Services below.
1212
* The plugin allows a Publish Collection to be converted to a Publish Collection Set - a Special Collection is created for the new Publish Collection Set and any photos that were in the converted Publish Collection will be in this Special Collection. This enables sub albums to be created under an album that was initially created for photos only.
1313
* Set Piwigo album cover from an image in the Published Collection
14-
* Album descriptions can be maintained by the plugin. Right-click on an album in the Publish Services panel to display dialog where Album Description can be edited - formatting tags (html markup) are sent unchanged so formatting can be managed. Existing descriptions will be imported from Piwigo if the Import Albums option is run, but these will not include the html markup.
14+
* Album descriptions can be optionally be maintained by the plugin. Useful for simple album descriptions but potentially descructive where complex album descriptions are in place on Piwigo - so use with enable this option with caution.
15+
* Check box in Publishing Manger - Synchronise Album Descriptions - will import album descriptions from Piwigo when Import Albums is run and store against each collection / set in the Publish Service. WARNING - formatting will not be imported from Piwigo so if you use complex album descriptions with formatting then you may lose these. Use with caution in this case.
16+
* Right-click on an album in the Publish Services panel to display dialog where Album Description can be edited - formatting tags (html markup) are sent unchanged so formatting can be managed from LrC. Existing descriptions will be imported from Piwigo if the Import Albums option is run, but these will not include the formatting - see WARNING above.
1517

1618
* 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.
1719
* the following fields are set :

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=20260106, minor=24, revision=0 },
62+
VERSION = { major=20260106, minor=25, 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 = "20260106.24"
75+
_G.pluginVersion = "20260106.25"
7676
--_G.LocStrings = utils.loadStrings()
7777

piwigoPublish.lrplugin/PiwigoAPI.lua

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,13 @@ local function createCollection(propertyTable, node, parentNode, isLeafNode, sta
729729
stat.errors = stat.errors + 1
730730
else
731731
collectionSettings = newColl:getCollectionInfoSummary().collectionSettings or {}
732-
collectionSettings.albumDescription = collDescription
733-
collectionSettings.albumPrivate = collStatus == "private"
732+
if propertyTable.syncAlbumDescriptions then
733+
collectionSettings.albumDescription = collDescription
734+
collectionSettings.albumPrivate = collStatus == "private"
735+
else
736+
collectionSettings.albumDescription = ""
737+
collectionSettings.albumPrivate = "public"
738+
end
734739
catalog:withWriteAccessDo("Add Piwigo details to collections", function()
735740
newColl:setRemoteId(remoteId)
736741
newColl:setRemoteUrl(propertyTable.host .. "/index.php?/category/" .. remoteId)
@@ -754,8 +759,14 @@ local function createCollection(propertyTable, node, parentNode, isLeafNode, sta
754759
else
755760
-- now add remoteids and urls to collections and collection sets, and description and status
756761
collectionSettings = newColl:getCollectionSetInfoSummary().collectionSettings or {}
757-
collectionSettings.albumDescription = collDescription
758-
collectionSettings.albumPrivate = collStatus == "private"
762+
if propertyTable.syncAlbumDescriptions then
763+
collectionSettings.albumDescription = collDescription
764+
collectionSettings.albumPrivate = collStatus == "private"
765+
else
766+
collectionSettings.albumDescription = ""
767+
collectionSettings.albumPrivate = "public"
768+
end
769+
759770
catalog:withWriteAccessDo("Add Piwigo details to collections", function()
760771
newColl:setRemoteId(remoteId)
761772
newColl:setRemoteUrl(propertyTable.host .. "/index.php?/category/" .. remoteId)
@@ -773,17 +784,28 @@ local function createCollection(propertyTable, node, parentNode, isLeafNode, sta
773784
-- existing collection
774785
log:info("createCollection - updating existing PublishedCollection " .. existingColl:getName())
775786
collectionSettings = existingColl:getCollectionInfoSummary().collectionSettings or {}
776-
collectionSettings.albumDescription = collDescription
777-
collectionSettings.albumPrivate = collStatus == "private"
787+
if propertyTable.syncAlbumDescriptions then
788+
collectionSettings.albumDescription = collDescription
789+
collectionSettings.albumPrivate = collStatus == "private"
790+
else
791+
collectionSettings.albumDescription = ""
792+
collectionSettings.albumPrivate = "public"
793+
end
794+
778795
catalog:withWriteAccessDo("Update Piwigo details to collections", function()
779796
existingColl:setCollectionSettings(collectionSettings)
780797
end)
781798
elseif existingColl:type() == "LrPublishedCollectionSet" then
782799
-- existing collection set
783800
log:info("createCollection - updating existing PublishedCollectionSet " .. existingColl:getName())
784801
collectionSettings = existingColl:getCollectionSetInfoSummary().collectionSettings or {}
785-
collectionSettings.albumDescription = collDescription
786-
collectionSettings.albumPrivate = collStatus == "private"
802+
if propertyTable.syncAlbumDescriptions then
803+
collectionSettings.albumDescription = collDescription
804+
collectionSettings.albumPrivate = collStatus == "private"
805+
else
806+
collectionSettings.albumDescription = ""
807+
collectionSettings.albumPrivate = "public"
808+
end
787809
catalog:withWriteAccessDo("Update Piwigo details to collections", function()
788810
existingColl:setCollectionSetSettings(collectionSettings)
789811
end)
@@ -1570,10 +1592,14 @@ function PiwigoAPI.pwCategoriesAdd(propertyTable, info, metaData, callStatus)
15701592
local Params = {
15711593
{ name = "method", value = "pwg.categories.add" },
15721594
{ name = "name", value = name },
1573-
{ name = "comment", value = description },
1574-
{ name = "status", value = albumstatus },
15751595
{ name = "pwg_token", value = propertyTable.token }
15761596
}
1597+
1598+
if propertyTable.syncAlbumDescriptions then
1599+
table.insert(Params, { name = "comment", value = description })
1600+
table.insert(Params, { name = "status", value = albumstatus })
1601+
end
1602+
15771603
if metaData.parentCat ~= "" then
15781604
table.insert(Params, { name = "parent", value = metaData.parentCat })
15791605
end
@@ -1716,11 +1742,12 @@ function PiwigoAPI.pwCategoriesSetinfo(propertyTable, info, metaData)
17161742
{ name = "method", value = "pwg.categories.setInfo" },
17171743
{ name = "category_id", value = tostring(remoteId) },
17181744
{ name = "name", value = name },
1719-
{ name = "comment", value = description },
1720-
{ name = "status", value = status },
17211745
{ name = "pwg_token", value = propertyTable.token }
17221746
}
1723-
1747+
if propertyTable.syncAlbumDescriptions then
1748+
table.insert(params, { name = "comment", value = description })
1749+
table.insert(params, { name = "status", value = status })
1750+
end
17241751
local httpResponse, httpHeaders = LrHttp.postMultipart(
17251752
propertyTable.pwurl,
17261753
params,
@@ -1946,7 +1973,6 @@ function PiwigoAPI.updateMetadata(propertyTable, lrPhoto, metaData)
19461973
return callStatus
19471974
end
19481975
if metaData.Remoteid ~= "" then
1949-
19501976
local rtnStatus = PiwigoAPI.checkPhoto(propertyTable, metaData.Remoteid)
19511977
if not rtnStatus.status then
19521978
log:info("PiwigoAPI.updateMetadata - checking for existing photo with remoteid " .. metaData.Remoteid)
@@ -2020,7 +2046,7 @@ function PiwigoAPI.updateMetadata(propertyTable, lrPhoto, metaData)
20202046
end
20212047
end
20222048

2023-
-- now update Piwigo
2049+
-- now update Piwigo
20242050
local postResponse = PiwigoAPI.httpPostMultiPart(propertyTable, params)
20252051
if not postResponse.status then
20262052
callStatus.statusMsg = "Unable to set metadata - " .. postResponse.statusMsg
@@ -2132,9 +2158,9 @@ function PiwigoAPI.specialCollections(propertyTable)
21322158
local name = thisSet:getName()
21332159
local scName = PiwigoAPI.buildSpecialCollectionName(name)
21342160
log:info("Processing collection set " ..
2135-
thisSet:getName() .. ", " .. scName .. ", remoteId " .. tostring(remoteId))
2161+
thisSet:getName() .. ", " .. scName .. ", remoteId " .. tostring(remoteId))
21362162
local scColl = PiwigoAPI.createPublishCollection(catalog, publishService, propertyTable, scName, remoteId,
2137-
thisSet)
2163+
thisSet)
21382164
if scColl == nil then
21392165
LrDialogs.message("Failed to create special collection for " .. name, "", "warning")
21402166
end

piwigoPublish.lrplugin/PublishDialogSections.lua

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ local function prefsDialog(f, propertyTable)
229229
width_in_chars = 50,
230230
tooltip = "Click to fetch the current album structure from the Piwigo Host above. Only albums the user has permission to see will be included",
231231
},
232+
232233
},
233234

234235
f:spacer { height = 1 },
@@ -290,8 +291,9 @@ local function prefsDialog(f, propertyTable)
290291
tooltip = "Piwigo structure will be checked against local collection / set structure. Missing Piwigo albums will be created and links checked / updated"
291292
},
292293
},
294+
295+
293296
},
294-
f:spacer { height = 2 },
295297

296298
f:group_box {
297299
title = "Metadata Settings",
@@ -372,6 +374,27 @@ local function prefsDialog(f, propertyTable)
372374
}
373375
},
374376
},
377+
f:spacer { height = 2 },
378+
f:group_box {
379+
title = "Other Settings",
380+
font = "<system/bold>",
381+
fill_horizontal = 1,
382+
f:spacer { height = 1 },
383+
f:row {
384+
fill_horizontal = 1,
385+
f:static_text {
386+
title = "",
387+
alignment = 'right',
388+
width_in_chars = 7,
389+
},
390+
f:checkbox {
391+
title = "Synchronise Album Descriptions",
392+
font = "<system>",
393+
tooltip = "If checked, Album descriptions will be maintainable in Lightroom and sent to Piwigo",
394+
value = bind 'syncAlbumDescriptions',
395+
},
396+
}
397+
},
375398
}
376399
end
377400
--

piwigoPublish.lrplugin/PublishServiceProvider.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ return {
5454
{ key = "KwSynonyms", default = true},
5555
{ key = "mdTitle", default = "{{title}}"},
5656
{ key = "mdDescription", default = "{{caption}}"},
57+
{ key = "syncAlbumDescriptions", default = false}
5758
--{ key = "scNameFix",default = false}
5859

5960
},

piwigoPublish.lrplugin/PublishTask.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ end
311311
-- ************************************************
312312
function PublishTask.getCommentsFromPublishedCollection(publishSettings, arrayOfPhotoInfo, commentCallback)
313313
log:info("PublishTask.getCommentsFromPublishedCollection")
314-
--[[
314+
--[[
315315
for i, photoInfo in ipairs(arrayOfPhotoInfo) do
316316
log:info("PublishTask.getCommentsFromPublishedCollection - photoInfo:\n" .. utils.serialiseVar(photoInfo))
317317
@@ -515,6 +515,11 @@ function PublishTask.viewForCollectionSettings(f, publishSettings, info)
515515
f:row {
516516
f:static_text { title = "Album Description:", font = "<system>", alignment = 'right', width = share 'label_width', },
517517
f:edit_field {
518+
enabled = LrView.bind {
519+
key = 'syncAlbumDescriptions',
520+
object = publishSettings,
521+
},
522+
518523
value = bind 'albumDescription',
519524
width_in_chars = 40,
520525
font = "<system>",
@@ -791,6 +796,10 @@ function PublishTask.viewForCollectionSetSettings(f, publishSettings, info)
791796
f:row {
792797
f:static_text { title = "Album Description:", font = "<system>", alignment = 'right', width = share 'label_width', },
793798
f:edit_field {
799+
enabled = LrView.bind {
800+
key = 'syncAlbumDescriptions',
801+
object = publishSettings,
802+
},
794803
value = bind 'albumDescription',
795804
width_in_chars = 40,
796805
font = "<system>",
@@ -861,6 +870,7 @@ function PublishTask.updateCollectionSetSettings(publishSettings, info)
861870
metaData.status = "public"
862871
end
863872

873+
864874
-- update albumdesc if album exists and set
865875
metaData.name = CollectionName
866876
metaData.type = "collectionset"
@@ -999,8 +1009,8 @@ function PublishTask.renamePublishedCollection(publishSettings, info)
9991009
-- need to check that remoteUrl is same as metadata field as photo may be in multiple publish collections
10001010
-- check all published photos in this collection
10011011
log:info(
1002-
"PublishTask.renamePublishedCollection - updating photo metadata in renamed collection - collection is a " ..
1003-
collection:type())
1012+
"PublishTask.renamePublishedCollection - updating photo metadata in renamed collection - collection is a " ..
1013+
collection:type())
10041014
if collection:type() == "LrPublishedCollection" then
10051015
-- only PublishedCollections have photos
10061016
PiwigoAPI.updateMetaDataforCollection(publishSettings, collection, metaData)

0 commit comments

Comments
 (0)