public ActionResult Index() { var properties = GetProperties(); IEnumerable <Picture> pictures = new List <Picture>(); switch (properties.Type) { case Type.Attachments: pictures = this.GetPage().Attachments.ToList().Where(a => a.AttachmentImageWidth > 0).Select(a => new Picture { Url = CMS.DocumentEngine.AttachmentURLProvider.GetAttachmentUrl(a.AttachmentName, this.GetPage().NodeAliasPath), AltText = a.AttachmentTitle, Thumbnail = $"{AttachmentURLProvider.GetAttachmentUrl(a.AttachmentName, this.GetPage().NodeAliasPath)}?maxsidesize=128" }); break; case Type.MediaLibraryFolder: /*var library = MediaLibraryInfoProvider.GetMediaLibraryInfo(properties.MediaLibraryFolder, this.GetPage().NodeSiteName); * if (string.IsNullOrEmpty(properties.MediaLibraryFolder)) * { * properties.MediaLibraryFolder = "%"; * } * var files = MediaFileInfoProvider.GetMediaFiles($"{nameof(MediaFileInfo.FileLibraryID)}={library.LibraryID} AND {nameof(MediaFileInfo.FilePath)} LIKE '{properties.MediaLibrarySubfolder}%'"); * pictures = files.ToList().Select(f => new Picture * { * Url = MediaLibraryHelper.GetMediaFileUrl(f.FileGUID, this.GetPage().NodeSiteName), * AltText = f.FileTitle, * Thumbnail = $"{MediaFileURLProvider.GetMediaFileAbsoluteUrl(this.GetPage().NodeSiteName, f.FileGUID, f.FileName)}?maxsidesize=120" * });*/ if (properties.MediaFiles != null) { pictures = properties.MediaFiles.Select(m => new Picture { Url = MediaLibraryHelper.GetMediaFileUrl(m.FileGuid, this.GetPage().NodeSiteName), AltText = MediaFileInfoProvider.GetMediaFileInfo(m.FileGuid, this.GetPage().NodeSiteName).FileTitle, Thumbnail = $"{MediaFileURLProvider.GetMediaFileAbsoluteUrl(this.GetPage().NodeSiteName, m.FileGuid, MediaFileInfoProvider.GetMediaFileInfo(m.FileGuid, this.GetPage().NodeSiteName).FileName)}?maxsidesize=128" }); } break; case Type.External: pictures = properties.External.Split(new[] { Environment.NewLine }, StringSplitOptions.None).Select(f => new Picture { Url = f, AltText = f, Thumbnail = f }); break; } var viewModel = new ViewModel { Pictures = pictures }; return(PartialView("Widgets/_LightboxGallery", viewModel)); }
public static ISearchDocument GetSearchDocument(MediaFileInfo fileInfo, SearchIndexInfo indexInfo) { var contentBuilder = new StringBuilder(); contentBuilder.Append(GetContent(fileInfo) + SEPARATOR); var doc = CMS.Search.SearchHelper.CreateDocument(new SearchDocumentParameters { Index = indexInfo, Type = CMS.Search.SearchHelper.CUSTOM_SEARCH_INDEX, Id = fileInfo.FileID.ToString(), Created = fileInfo.FileCreatedWhen }); var keywords = fileInfo.GetValue("FileKeywords")?.ToString() ?? string.Empty; var mediaLibrary = MediaLibraryInfoProvider.GetMediaLibraryInfo(fileInfo.FileLibraryID); contentBuilder.Append(fileInfo.FileTitle + SEPARATOR); contentBuilder.Append(fileInfo.FileDescription + SEPARATOR); contentBuilder.Append(fileInfo.FileCustomData + SEPARATOR); contentBuilder.Append(fileInfo.FileName + SEPARATOR); contentBuilder.Append(keywords + SEPARATOR); CMS.Search.SearchHelper.AddGeneralField(doc, SearchFieldsConstants.CONTENT, HTMLHelper.HtmlToPlainText(contentBuilder.ToString()), false, true); CMS.Search.SearchHelper.AddGeneralField(doc, "Keywords", keywords, true, true); CMS.Search.SearchHelper.AddGeneralField(doc, SearchFieldsConstants.CUSTOM_TITLE, fileInfo.FileName, true, false, true); CMS.Search.SearchHelper.AddGeneralField(doc, SearchFieldsConstants.CUSTOM_DATE, fileInfo.FileCreatedWhen, true, false); CMS.Search.SearchHelper.AddGeneralField(doc, SearchFieldsConstants.CUSTOM_IMAGEURL, MediaLibraryHelper.GetMediaFileUrl(fileInfo.FileGUID, SiteInfoProvider.GetSiteInfo(fileInfo.FileSiteID).SiteName), true, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileName), fileInfo.FileName, true, false, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileDescription), fileInfo.FileDescription, true, false, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileGUID), fileInfo.FileGUID, true, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileLibraryID), fileInfo.FileLibraryID.ToString(), true, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FilePath), fileInfo.FilePath, true, false, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileMimeType), fileInfo.FileMimeType, true, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileImageWidth), fileInfo.FileImageWidth.ToString(), true, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileImageHeight), fileInfo.FileImageHeight.ToString(), true, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaFileInfo.FileSize), fileInfo.FileSize, true, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaLibraryInfo.LibraryDisplayName), mediaLibrary.LibraryDisplayName, true, false, false); CMS.Search.SearchHelper.AddGeneralField(doc, nameof(MediaLibraryInfo.LibraryFolder), mediaLibrary.LibraryFolder, true, false, false); return(doc); }