Skip to main content
Blatman888
Participating Frequently
September 18, 2008
Question

Accessing custom metadata from Web Engine gallery

  • September 18, 2008
  • 16 replies
  • 4950 views
Hi folks - using LR 2.0 and slogging through the SDK and Web Engine stuff.
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.
This topic has been closed for replies.

16 replies

Blatman888
Participating Frequently
April 6, 2009

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

New Participant
February 3, 2015

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

johnrellis
Brainiac
February 4, 2015
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" %>

Blatman888
Participating Frequently
March 25, 2009
Thanks Matt,

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
DawMatt
Inspiring
March 24, 2009
Sean, Blane,

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
Blatman888
Participating Frequently
March 8, 2009
Unfortunately my last post didn't show all the HTML details but it does show if the Page Source is viewed - this will make the examples clearer.
Cheers.
Sean McCormack
Adobe Expert
March 8, 2009
62,003 restarts is why I want a restart shortcut key :)

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.
Sean McCormack. Author of 'Essential Development 3'. Magazine Writer. Former Official Fuji X-Photographer.
Blatman888
Participating Frequently
March 7, 2009
Hello again folks,<br />Been trying a few things and have now managed to extract custom<br />metadata from the catalog (via plugin) into a table which can be<br />written into the index.html page produced by the web engine. Once <br />in the XHTML page the data can be DOM parsed with javascript and<br />used appropriately.<br /><br />Code in galleryInfo.lrweb file ::<br />(thanks Chet for your guidance earlier in thread)<br /><pre><br /><br />-- placed before return { at top of file<br /><br /> START<br /> local LrApplication = import 'LrApplication'<br /> local LrDialogs = import 'LrDialogs'<br /> local LrStringUtils = import 'LrStringUtils'<br /><br /> catalog = LrApplication.activeCatalog()<br /> catalog:withReadAccessDo( function()<br /> photos = catalog.allPhotos<br /> end )<br /> local container1 = "<div>" .. "\n" -- omit if hippo array used<br /> local buffString = "" .. container1<br /><br /> for i, photo in ipairs(photos) do<br /> biggo = nil<br /> catalog:withReadAccessDo( function()<br /> biggo = photo:getPropertyForPlugin( 'nz.org.wh.metadata.photogallerynotes', 'notes' )<br /> end )<br /><br /> local tagno = i<br /> local tag = '<span id="pgs' .. tagno .. '" class="thickbox">'<br /> if biggo ~= nil then <br /> tnotes = LrStringUtils.trimWhitespace(biggo)<br /> tag = tag .. tnotes .. "</span>" .. "\n"<br /> else<br /> tag = tag .. "</span>" .. "\n" <br /> end<br /><br /> hippo = tag -- alternative is to populate an array, working on this<br /> <br /> buffString = buffString .. tag<br /> end -- for/do<br /> <br /> buffString = buffString .. "</div>"<br /><br /> local notes = buffString -- use if span's in div required, hippo array doesn't require<br /><br /> FINISH<br /> <br /> buffString (or notes) should give something like -<br /> <br /> <div><br /> <span id="pgs1" class="thickbox">1st photo notes</span><br /> <span id="pgs2" class="thickbox">2nd photo notes</span><br /> ..... etc<br /> </div><br /> <br /> The notes variable can be attached to a model item -<br /> <br /> eg: ["nonCSS.hippo"] = notes,<br /> <br /> This model item can then be inserted into the XHTML index template using<br /> <br /> <%= metadata.notes %> type notation.<br /> <br /> Once embedded in the index page the data can be extracted with javascript<br /> DOM parsing and then styled etc.<br /> <br /> Ideally I wanted to take each unique span id line and use it in the grid<br /> (this can be done with the com.adobe metadata OK) along with cellIndex but just <br /> can't manage to get it to work (closest I get is Table 0E444720 or whatever).<br /> I used the hippo array to store the unique span id's -<br /> eg:<br /> in galleryInfo -<br /> ["metadata.notes3"] = hippo[3],<br /> then in XHTML template -<br /> <%= model.metadata.notes3 %> <br /> Result: <span id="pgs3" class="thickbox">3rd photo notes</span> <br /> Works fine (but can't use hard-coded number in GridPhotoCell repetitively)<br /> <br /> in galleryInfo -<br /> ["metadata.notes"] = hippo,<br /> then in XHTML template -<br /> <%= model.metadata.notes %>[<%= cellIndex %>] <br /> Result: table: 0E444720[3]<br /> No good<br /> <br /> STOP PRESS::::<br /> Tried - hippo array method<br /><br />function initializeArray ( elementCount )<br /><br /> local tmpArray = {}<br /><br /> for i=1, elementCount do<br /> tempArray = 0<br /> end<br /><br /> return tmpArray<br />end<br /><br />hippo = initializeArray ( 13 )<br /> <br /> in galleryInfo -<br /> ["metadata.notes"] = hippo,<br /> then in XHTML template -<br /> <%= model.metadata.notes[cellIndex] %><br /> Result: <span id="pgsx" class="thickbox">x photo notes</span> <br /> Damn good!!!!!!!!!! Life is good again!<br /> <br /> I can now get something like -<br /> <lr:GridPhotoCell><br /> <div class="frame"><br /> <a id="pg-3" href="#nogo" onmouseover="xshow_notes('3')" onclick="load_snap('3')" rel="ja" title="Typical farming homestead"><span class="itemNumber">3</span><img src="images/pg/thumb/ja_03.jpg" alt="pg 3" class="gallerythumb" title="" /></a><br /> <span id="pgs3" class="thickbox">You could almost be forgiven that it was Switzerland! The coos (Scottish accent there) looked healthy enough.</span><br /> <span id="pge3">Canon EOS 5D,EF24-105mm f/4L IS USM,1/100 sec at f / 13,ISO 100,Shutter priority,Did not fire,,-2/3 EV,Pattern,28 mm,02/07/2007 10:41:29,600 x 400</span><br /> <span id="pgi3">BlatSnap,UK,© BlatSnap</span><br /> <span id="ifn3">ja_03</span><br /> </div><br /> </lr:GridPhotoCell> <br /> <br /> So after c. 62,003 restarts of LR I can now move custom metadata from the Library module<br /> in the WebEngine to exported web pages.<br /> <br /> I think this code can also be shifted to a button in the UI panel<br /> which I have learn't how to use by perusing the Fotoplayer plugin.<br /> (Thanks again Chet for the clue that buttons can be used in the WE)<br /> This would allow notes to be updated in Library then processed in the WE.<br /> <br /> As a sidenote this code can be used along with the LrXML and LrLogger to produce XML dumps of all<br /> metadata.<br /> <br /> I suppose a new version will now appear from Adobe that will do this elegantly in c. 3 lines ... :)<br /> - and a lot less heavy animal references.<br /> <br /></pre>
New Participant
October 18, 2008
Did you remember to put "local LrPhoto = import 'LrPhoto'" somewhere before this?
New Participant
October 15, 2008
Chet,

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).
Sean McCormack
Adobe Expert
October 13, 2008
Blane,
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...
Sean McCormack. Author of 'Essential Development 3'. Magazine Writer. Former Official Fuji X-Photographer.
Blatman888
Participating Frequently
October 11, 2008
Yes John I agree - it did cross my my mind about being able to add custom metadata to the library module but not being able to use it in another module. I guess Adobe has this sort of thing in the 'pipeline' for a later version and I suppose that is what SDK's are all about. It does seem though that the modules are being developed somewhat as separate 'silos' in some cases - interestingly I was looking at the Slide module the other day and was thinking about the Text Overlay feature which is nice and adjustable for font/size/position, etc and I thought how good would this be if it could be used as the Watermark in the Web Module ( at the moment I just exit the 'professional' app and use Faststone to do watermarks).
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!