It took a little searching to find the logic for filtering image libraries by a tag, so I thought I'd post it here:
Private Function GetLibraryImageList(ByRef strFileList() As String, ByRef strAuthorList() As String, ByRef strAltTextList() As String) As Boolean ' create sitefinity library manager Dim libManager As New LibraryManager("Libraries") Dim mgrContent as new ContentManager("Libraries") Dim lstTags as IList = Nothing Dim strImageName as String = "" Dim strImageAuthor as String = "" Dim strImageAltText as String = "" Dim intIndex as Integer = 0 Dim lstImage as IContent Dim strImageItemInfo as String = "" Dim libImage as ILibrary = libManager.GetLibrary(ImageGalleryName) Dim listOfImages as IList = Nothing Dim strRequestedTagList() as String = Split(FilterTagList, ",") Dim strMimeType as String = "" ' get Library Dim parentIDs(1) as Guid parentIDs(0) = libImage.ID strFileList = Nothing strAuthorList = Nothing strAltTextList = Nothing If FilterTagList.Trim <> "" Then ' User is requesting tag filtering For Each strRequestedTag as String In strRequestedTagList ' Each requested tag to filter on listOfImages = mgrContent.GetContent(0, MaxImageCount, "Publication_Date desc", strRequestedTag) Next Else ' get all images For specific library listOfImages = libManager.GetImages(0, MaxImageCount, "Publication_Date DESC", parentIDs) End If ReDim strFileList(listOfImages.Count) ReDim strAuthorList(listOfImages.Count) ReDim strAltTextList(listOfImages.Count) For Each lstImage In listOfImages strImageName = lstImage.UrlWithExtension strImageAuthor = lstImage.GetMetaData("Author") strImageAltText = lstImage.GetMetaData("AlternateText") strFileList(intIndex) = strImageName strAuthorList(intIndex) = strImageAuthor strAltTextList(intIndex) = strImageAltText IntIndex += 1 Next Return True End Function
RadEditor - please enable JavaScript to use the rich text editor.
I often get asked why I'm willing to journal all of my Sitefinity discoveries. People think I'm insane to give away for free what I labored over at some point.
Let me answer that in 2 parts:
Talk to us about how we can help YOU!
Keep up with our Sitefinity discoveries! Click on the RSS feed icon below or sign up for our newsletter.