Accessing custom metadata from Web Engine gallery
Copy link to clipboard
Copied
Basically, can custom metadata fields from a plugin be accessed from a Web Engine at all and if so how?
I have managed to create a custom metadata field (I don't really want to use one of the inbuilt dedicated metadata fields) in the Library module and it works fine, I can add notes to each image and the info is kept in the Catalog not in the XMP or with image (SDK says this) however I wish to access this field from the Web Gallery via the galleryInfo.lrweb file but not sure how or if it can be done.
My custom plugin name is "nz.org.wh.metadata.photogallerynotes" and the field id (set in metadataFieldsForPhotos = { part of plugin ) is "notes".
I tried using the perImageSettings parameter with "nz.org.wh.metadata.photogallerynotes.notes" as a value but no good - I think maybe that the perImageSetting parameter can only be used with "com.adobe" type fields such as title, caption, etc. Maybe I am asking for a LR 3.0 DCR ... :-)
Cheers.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
local catalog = import'LrApplication'.activeCatalog()
catalog:withWriteAccessDo('some_string', function()
local photos = catalog:findPhotosWithProperty('nz.org.wh.metadata.photogallerynotes', 'notes')
for i, v in ipairs(photos) do
-- whatever it is you want to do with these photos...
end
end)
In my own experiment, this code appears inside the 'action' function for a button which appears in a panel for my web engine gallery, and the property was written by a plug-in appearing as a 'plug-in extra'.
The above code assumes, of course, that the 'notes' property was successfully written at some point in the past by the plugin identified by 'nz.org.wh.metadata.photogallerynotes'
Hope this helps.
Copy link to clipboard
Copied
Alternatively I was thinking that if the notes metadata could somehow be inserted (and be selectable) into the Text Template Editor that is used from the UI panels then that may provide a key.
Cheers.
Copy link to clipboard
Copied
I just realized (and verified) that I can define custom tags to get at custom metadata for display with each photo in the grid view (and presumably other views as well). In the definition of the custom tags, you have the opportunity to write LUA functions which dig into the custom metadata using LrPhoto:getPropertyForPlugin, LrCatalog:findPhotosWithProperty, etc. Custom tags are described in the SDK guide.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Probably if I can't work out all the Lua stuff eventually I'll have to just write the notes into the XHTML pages directly and forget about entering the info as metadata in the catalog - tedious!
Copy link to clipboard
Copied
The guy doing the Web Module and the Slideshow Module are one and the same: Andy Rahn (Hi Andy!). Better watermarking would be great indeed...
Copy link to clipboard
Copied
How did you use LrPhoto:GetPropertyForPlugin?
I get an error when using it: Galleries\mysample.lrwebengine\myExampleTags.lrweb:41: attempt to index global 'LrPhoto' (a nil value).
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Nice work Blane, although it takes some reading.
I've literally only started calling LrColor inside a Web Engine and am working my way through the rest of the [non Web] SDK.
Copy link to clipboard
Copied
Cheers.
Copy link to clipboard
Copied
Not quite a "restart shortcut key" but I have just posted a Lightroom restart script here:
http://thephotogeek.com/lightroom-power-nap-restart-script/
Makes those 62,003 restarts a one step process at least. :-)
Matt
Copy link to clipboard
Copied
seems to work OK and will save a few keystrokes whilst I fumble about in the not so 'light' room with this Lua stuff.
Cheers,
Blane
Copy link to clipboard
Copied
Here we go - the forums have changed so I have attached a text file with the html/lua stuff which should make a lot more sense.
Cheers,
Blane
Copy link to clipboard
Copied
Have things advanced in Lightroom to support access to custom metadata in a web gallery plugin? @Blatman888, I have tried to understand the workflow in fixup.txt, but with no luck. Are there sample plugins that can be reviewed?
I recently posted this question on stackexchange looking for help:
lua - In Lightroom how do you reference custom metadata in a web plugin? - Stack Overflow
Thanks,
Craig
Copy link to clipboard
Copied
No.
Copy link to clipboard
Copied
Have things advanced in Lightroom to support access to custom metadata in a web gallery plugin?
I don't totally understand the web engine, but I was able to modify the SDK example "mysample.lrwebengine" to show another plugin's custom metadata field underneath the image shown on "large.html". The basic idea is to map the image proxy returned by getImage(index) to its corresponding LrPhoto in the catalog, using the image proxy's "imageID" property. That "imageID" property is the the same as the underlying photo's "localIdentifier" property. Once you have an LrPhoto, you can use the photo:getPropertyForPlugin() method to retrieve the custom metadata field for any plugin.
Here's a modified version of "large.html" that displays the metadata field "file" of the plugin "com.johnrellis.anyfile" underneath the image:
<%
--[[ Define some variables to make locating other resources easier.]]
local image = getImage( index )
local theRoot = ".."
local others = "."
local mySize = "large"
--[[ Code added by John R. Ellis ]]
local LrApplication = import 'LrApplication'
local catalog = LrApplication.activeCatalog ()
local idToPhoto = {}
for _, photo in ipairs (catalog:getAllPhotos ()) do
idToPhoto [photo.localIdentifier] = photo
end
local photo = idToPhoto [image.imageID]
local anyfileFile = photo:getPropertyForPlugin ("com.johnrellis.anyfile", "file")
--[[ End code added by John R. Ellis ]]
%>
<% --[[ Include the page header]] %>
<%@ include file="header.html" %>
<div>
<ul>
<lr:Pagination>
<lr:PreviousEnabled>
<li><a href="$link">Previous</a></li>
</lr:PreviousEnabled>
<lr:PreviousDisabled>
<li>Previous</li>
</lr:PreviousDisabled>
<li><a href="$gridPageLink">Index</a></li>
<lr:NextEnabled>
<li><a href="$link">Next</a></li>
</lr:NextEnabled>
<lr:NextDisabled>
<li>Next</li>
</lr:NextDisabled>
</lr:Pagination>
</ul>
</div>
<a href="$gridPageLink">
<img src="bin/images/large/<%= image.exportFilename %>.jpg" />
</a>
<pre> <%= --[[ Code added by John R. Ellis ]]
"Value of com.johnrellis.anyfile:file -- " .. (anyfileFile or "")
--[[ End of code added by John R. Ellis ]] %>
</pre>
<xmpl:aQuote>You know what they say:<br>
<xmpl:saying> <br />....how interesting!<br /></xmpl:saying>
</xmpl:aQuote>
<% --[[ Include the page footer]] %>
<%@ include file="footer.html" %>
Copy link to clipboard
Copied
Thank you. Very helpful. Sorry to ask for this, but how would you do it if you were to add custom metadata to the grid.html, perhaps adding the metadata below the thumbnail?
Craig
Copy link to clipboard
Copied
<%
--[[ Define some variables to make locating other resources easier.]]
local mySize = "thumb"
local others = "content"
local theRoot = "."
--[[ Code added by John R. Ellis ]]
local LrApplication = import 'LrApplication'
local catalog = LrApplication.activeCatalog ()
local idToPhoto = {}
for _, photo in ipairs (catalog:getAllPhotos ()) do
idToPhoto [photo.localIdentifier] = photo
end
--[[ End code added by John R. Ellis ]]
%>
<% --[[ Include the page header]] %>
<%@ include file="header.html" %>
<lr:ThumbnailGrid>
<lr:GridPhotoCell>
<a href="$others/<%= image.exportFilename %>_large.html">
<% --[[ Code added by John R. Ellis ]]
local photo = idToPhoto [image.imageID]
local anyfileFile = photo:getPropertyForPlugin ("com.johnrellis.anyfile", "file")
--[[ End code added by John R. Ellis ]]
%>
<img src="$others/bin/images/thumb/<%= image.exportFilename %>.jpg" id="<%= image.imageID %>" class="thumb" />
</a>
<%= --[[ Code added by John R. Ellis ]]
anyfileFile %>
</lr:GridPhotoCell>
</lr:ThumbnailGrid>
<% if numGridPages > 1 then %>
<div class="pagination">
<ul>
<lr:Pagination>
<lr:CurrentPage>
<li>$page</li>
</lr:CurrentPage>
<lr:OtherPages>
<li><a href="$link">$page</a></li>
</lr:OtherPages>
<lr:PreviousEnabled>
<li><a href="$link">Previous</a></li>
</lr:PreviousEnabled>
<lr:PreviousDisabled>
<li>Previous</li>
</lr:PreviousDisabled>
<lr:NextEnabled>
<li><a href="$link">Next</a></li>
</lr:NextEnabled>
<lr:NextDisabled>
<li>Next</li>
</lr:NextDisabled>
</lr:Pagination>
</ul>
</div>
<% end %>
<% --[[ Include the page footer]] %>
<%@ include file="footer.html" %>
Copy link to clipboard
Copied
Brilliant. John, thank you for the great example.
Craig

