Skip to main content
Known Participant
October 6, 2013
Question

ordinal position of images in catalog (which is the same as the filmstrip order?)

  • October 6, 2013
  • 1 reply
  • 966 views

i'm using LrTasks to getAllPhotos in hopes of putting some image navigation inside my plugin module.  i can get a list of images this way and even use them for my in-plugin navigation, but the order of the images is different from the order in the Lightroom "filmstrip" (or whatever that thing at the bottom of lightroom's main window is called).  question:  how do i get the ordinal position of images in that filmstrip using the SDK/API?

This topic has been closed for replies.

1 reply

areohbee
Legend
October 6, 2013

My function for getting photos in filmstrip, for example purposes (requires Elare Plugin Framework to function):

--- Get photos visible in filmstrip (as filtered, as stacked, ... ).
--
--  @usage without disturbing users's present selection.
--
--  @param selectedPhoto (LrPhoto, default=nil) catalog:getTargetPhoto() - in case already available in calling context.
--  @param selectedPhotos (array of LrPhoto, default=nil) catalog:getTargetPhotos() - ditto.
--  @param metadataCache (LrMetadata::Cache, optional) metadata cache.
--  @param includeIfBuried (boolean, default=false) visible only? or those underneath in collapsed stacks too.
--
--  @return visiblePhotos (array) never nil, but may be empty (e.g. virgin catalog)
--
function Catalog:getVisiblePhotos( params )
    -- works in Lr3+4+5/win7; ###1 test on Mac.
    params = params or {}
    local selectedPhoto = params.selectedPhoto or catalog:getTargetPhoto()
    local selectedPhotos = params.selectedPhotos or catalog:getTargetPhotos()
    local visiblePhotos
    if selectedPhoto then
        catalog:setSelectedPhotos( selectedPhoto, {} )
        local allVisiblePhotos = catalog:getMultipleSelectedOrAllPhotos()
        catalog:setSelectedPhotos( selectedPhoto, selectedPhotos )
        --Debug.pause( #allVisiblePhotos, #selectedPhotos, #selectedPhotos == #catalog:getTargetPhotos() ) 
        visiblePhotos = allVisiblePhotos
    else
        visiblePhotos = selectedPhotos
    end
    if not params.includeIfBuried or #visiblePhotos == 0 then
        return visiblePhotos
    end
    -- fall-through => include underlings.
    local cache = params.metadataCache or lrMeta:createCache{ photos=visiblePhotos, rawIds={ 'isInStackInFolder', 'stackInFolderIsCollapsed', 'stackInFolderMembers', } }
    local buriedPhotos = {}
    for i, photo in ipairs( visiblePhotos ) do
        repeat                
            if not cache:getRawMetadata( photo, 'isInStackInFolder' ) then
                break
            end
            -- photo is in stack
            if not cache:getRawMetadata( photo, 'stackInFolderIsCollapsed' ) then
                break
            end
            -- stack is collapsed, therefore it is top of stack (actually, that is only true if source is folder - viewing collection, one could view underlings of collapsed folder stacks).
            local stack = cache:getRawMetadata( photo, 'stackInFolderMembers' )
            --assert( stack[1] == photo, "tos?" ) - invalid assertion (see comment above).
            for j, stackedPhoto in ipairs(stack) do
                if photo ~= stackedPhoto then
                    buriedPhotos[#buriedPhotos + 1] = stackedPhoto
                end
            end
        until true
    end
    tab:appendArray( visiblePhotos, buriedPhotos ) -- returns promptly if no buried photos.
    return visiblePhotos
end
Known Participant
October 6, 2013

i'm using the Elare framework so it does work but it still returns a list of photos in an order that does not match the order of the filmstrip. i was wondering if that order indication (an "ordinal number" if you will) exists in the meta data somewhere.

areohbee
Legend
October 6, 2013

I thought order was same as filmstrip, other than stack underlings which are appended to the end. I guess I don't know the answer to your question then - sorry..

PS - Did you borrow the Elare framework from one of my plugins, download it from assembla, or did I send you a fresh zip copy?

R