protected void Page_Load(object sender, EventArgs e) { Size = Parameters.Get("Size", 2); if (EnableSef) { MapVariable(Parameters.Get<string>("SEFFolder", "/photogallery"), Parameters.Get<string>("SEF_Photo"), Results); } else { BXParamsBag<string> variableAlias = new BXParamsBag<string>(); variableAlias["PhotoId"] = Parameters.Get<string>("ParamPhoto", "photo"); MapVariable(variableAlias, Results); } if (PhotoId > 0) { BXIBlockElement photoItem = BXIBlockElement.GetById(PhotoId); if (photoItem != null) { if (photoItem.Sections.Count > 0) { int albumId = photoItem.Sections[0].SectionId; BXFilter photoFilter = new BXFilter(); photoFilter.Add(new BXFilterItem(BXIBlockElement.Fields.Sections.Section.ID, BXSqlFilterOperators.Equal, albumId)); PhotoItems = BXIBlockElement.GetList(photoFilter,null,new BXSelectAdd(BXIBlockElement.Fields.DetailImage,BXIBlockElement.Fields.PreviewImage),null); } else { PhotoItems = new BXIBlockElementCollection(); PhotoItems.Add(photoItem); } foreach (BXIBlockElement photo in PhotoItems) { if (PhotoId == photo.Id) SelectedIndex = PhotoItems.IndexOf(photo); Results["Preview" + photo.Id.ToString()] = string.Empty; BXFile image = photo.DetailImageId > 0 ? photo.DetailImage : photo.PreviewImage; if (image == null) continue; BXParamsBag<object> vars = new BXParamsBag<object>(); vars["PhotoId"] = photo.Id; Results["PHOTO_LINK_" + photo.Id.ToString()] = MakeLink(Parameters.Get<string>("UrlTemplatePhoto", BXConfigurationUtility.Constants.ErrorHref), vars); // if we've found preview file with needed dimensions stored in cash folder, we return it Bitrix.Services.Image.BXImageInfo imageInfo = Bitrix.Services.Image. BXImageUtility.GetResizedImage(image, PreviewWidth, PreviewHeight); Results["Preview" + photo.Id.ToString()] = imageInfo.GetUri(); Results["PreviewWidth" + photo.Id.ToString()] = imageInfo.Width; Results["PreviewHeight" + photo.Id.ToString()] = imageInfo.Height; } } if (Size > PhotoItems.Count) Size = PhotoItems.Count; IncludeComponentTemplate(); } }