This project is read-only.

Need filenames to display under images

Jan 23, 2014 at 7:45 PM
I've installed PhotoHandler. It works great, but I need the filenames to display under the images - just under the preview images would be fine or the thumbnails and preview both.

It can't be that difficult, being that the folder names display under the folder icons, but I can't for the life of me figure it out. I've tried everything I can think of, but not being well versed in ASP.NET or C#, I'm completely stuck. I see the code in the Album.ashx file for the image caption/file name at about line 982, but I don't know how to reference it in the Template.aspx file to get it to show up, and for all I know, maybe that's not the code to reference.

Can anyone help?

Thanks
Jan 27, 2014 at 11:36 PM
Edited Jan 27, 2014 at 11:37 PM
I know this PhotoHandler hasn't had much activity in a long while, but in case anyone needs the filenames to appear under the thumbnails or preview images, I figured out what part of the code to modify.

In the Album.ashx file, for the file names to appear under the thumbnails, find this block of code (at approx. lines 1988-2005):
           List<ImageInfo> images = Images;
            if (images != null && images.Count > 0) {
                foreach (ImageInfo image in images) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, ImageDivCssClass);
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, image.Link, true);
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    writer.AddAttribute(HtmlTextWriterAttribute.Src, image.IconUrl, true);
                    writer.AddAttribute(HtmlTextWriterAttribute.Alt, DisplayImageTooltip, true);
                    writer.RenderBeginTag(HtmlTextWriterTag.Img);
                    writer.RenderEndTag(); // img
                    writer.RenderEndTag(); // a
                    writer.WriteBreak();
                    writer.Write("&nbsp;");
                    writer.RenderEndTag(); // div
                }
            }
        }
Replace it with this block of code:
            List<ImageInfo> images = Images;
            if (images != null && images.Count > 0) {
                foreach (ImageInfo image in images) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, ImageDivCssClass);
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, image.Link, true);
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    writer.AddAttribute(HtmlTextWriterAttribute.Src, image.IconUrl, true);
                    writer.AddAttribute(HtmlTextWriterAttribute.Alt,
                         String.Format(DisplayImageTooltip, image.Caption), true);
                    writer.RenderBeginTag(HtmlTextWriterTag.Img);
                    writer.RenderEndTag(); // img
                    writer.WriteBreak();

                    writer.RenderEndTag(); // a
                    writer.Write(image.Caption);
                    writer.RenderEndTag(); // div
                }
            }
        }

For filenames to appear under the Preview image, find this block of code (at approx. lines 2197-2206):
           writer.AddAttribute(HtmlTextWriterAttribute.Href, pictPath, true);
            writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.AddAttribute(HtmlTextWriterAttribute.Src, Image.PreviewUrl, true);
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, DisplayFullResolutionTooltip, true);
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag(); // img
            writer.RenderEndTag(); // a

            writer.RenderEndTag(); // td
And replace it with this block of code:
           writer.AddAttribute(HtmlTextWriterAttribute.Href, pictPath, true);
            /// writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
            /// writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.AddAttribute(HtmlTextWriterAttribute.Src, Image.PreviewUrl, true);
            /// writer.AddAttribute(HtmlTextWriterAttribute.Alt, DisplayFullResolutionTooltip, false);
            writer.AddAttribute(HtmlTextWriterAttribute.Alt,
                       String.Format(DisplayImageTooltip, Image.Caption), false);
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag(); // img
            writer.WriteBreak();
            /// writer.RenderEndTag(); // a
            writer.Write(Image.Caption);
            writer.RenderEndTag();// td