Skip to main content
Participant
October 22, 2013
Answered

recordPublishedPhotoId and with setPropertyForPlugin before that

  • October 22, 2013
  • 1 reply
  • 1284 views

Hello,

I'm building my first Lightroom plugin and i'm having trouble dealing with processRenderedPhotos(). Images are being uploaded to a service (RESTful API) and the service response contains some metadata I need to set to the photo. I'm doing:

photo.catalog:withWriteAccessDo( "publishing", function( context )

    -- bla bla, image was uploaded

    photo:setPropertyForPlugin( _PLUGIN, "someKey", "someValue" )
    rendition:recordPublishedPhotoId( remoteId

end )

The problem is that by calling photo:setPropertyForPlugin(), my image goes into the "Modified Photos to Re-Publish" queue instead of being in the "Published" one. If i don't call the setPropertyForPlugin() method, the image is moved into the "Published photos" section.

I belive the withWriteAccessDo() has a delay and my rendition:recordPublishedPhotoId() call is actually performed BEFORE the writes to the LrPhoto object, hence the moving of that image to the "modified" queue (sometimes I can even see the UI shoing the image in the "Published" queue and then it refreshes and moves into the modified one).

Please help

Thank you!

This topic has been closed for replies.
Correct answer areohbee

After setting the property and returning from the catalog-with-do method, reset the modified-for-republish flag to what it was before, or what you want it to be (hint: publishedPhoto:setEditedFlag( desiredValue ). Note: you'll have to go back into another catalog-with-do method.

This multi-stage catalog updating became so common in my code that I built it into a single multi-phased catalog-access-wrapper method - maybe that was overkill, but food for thought...

Rob

1 reply

egzplicitAuthor
Participant
October 22, 2013

So far it seems that the re-publish is triggere because the "someKey" is present in the metadataThatTriggersRepublish table. If I remove it from there, calling the setPropertyForPlugin() method and then calling recordPublishedPhotoId() works just fine.

Is there a way aroudn this? I still want the "someKey" custom metadata to trigger a republish when the user changes it via the Lightroom UI, however I don't want the republish to happen when the actual plugin is changing it via photo:setPropertyForPlugin() inside the processRenderedPhotos() method.

areohbee
areohbeeCorrect answer
Legend
October 22, 2013

After setting the property and returning from the catalog-with-do method, reset the modified-for-republish flag to what it was before, or what you want it to be (hint: publishedPhoto:setEditedFlag( desiredValue ). Note: you'll have to go back into another catalog-with-do method.

This multi-stage catalog updating became so common in my code that I built it into a single multi-phased catalog-access-wrapper method - maybe that was overkill, but food for thought...

Rob

egzplicitAuthor
Participant
October 22, 2013

That makes sense, thank you. Did not spot the setEditedFlag() method inside the LrPublishedPhoto class. I've tried to do it your way and it seems to work, the only annoying thing is the UI refresh: when a new photo is added to a published collection and the user presses "Publish", 1st the image is uploaded to the remote service, then the metadata is set based on the service reply: this cause the image to go into the "modified photos for re-publish" queue for a tiny bit, until the other catalog-with-do method kicks in and sets the flag back to false.

Before reading your reply, I fixed this by using exportContext.publishedCollection:addPhotoByRemoteId() called from the 1st (and only, in this case) catalog-with-do method. In the documentation it states that if the photo is already published, it will just update the remoteId property, but actually it's also setting the edited flag to false. This causes no jumping of the image inside the "modified photos for re-publish" queue and it makes it go straight into the "published" one... however, it is a hack and not the right way of doing it