AYUDARME A PONER UNA GALERIA DE FOTOS wena....
Quiero poner una exposicion de fotos en mi web, y weno ( se que algunos se enfadaran conmigo :D ) las plantillas del Fronpuag, :D no me gustan... y queria eso.. una plantilla para ver fotos.. y que esten bien presentadas :D
un saludo graciaas.. :-} |
Codigo: ASPX con VB.
Ficheros: 2 ( thu.aspx y galeria.aspx ) thu.aspx: <%@Import Namespace="System.Drawing.Imaging" %> <script language="VB" runat="server"> Dim homedir As String Function ThumbnailCallback() as Boolean Return False End Function Sub Page_Load(sender as Object, e as EventArgs) homedir += Request.QueryString("path") 'Read in the image filename to create a thumbnail of Dim imageUrl as String = Request.QueryString("img") 'Read in the width and height Dim imageHeight as Integer = Request.QueryString("h") Dim imageWidth as Integer = Request.QueryString("w") 'Make sure that the image URL doesn't contain any /'s or \'s If imageUrl.IndexOf("/") >= 0 Or imageUrl.IndexOf("\") >= 0 then 'We found a / or \ Response.End() End If 'Add on the appropriate directory imageUrl = homedir & imageUrl Dim fullSizeImg as System.Drawing.Image fullSizeImg = System.Drawing.Image.FromFile(imageUrl) 'Do we need to create a thumbnail? Response.ContentType = "image/jpeg" If imageHeight > 0 and imageWidth > 0 then Dim dummyCallBack as System.Drawing.Image.GetThumbNailImageAbort dummyCallBack = New _ System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback) Dim thumbNailImg as System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(imageWidth, imageHeight, _ dummyCallBack, IntPtr.Zero) thumbNailImg.Save(Response.OutputStream, ImageFormat.jpeg) Else fullSizeImg.Save(Response.OutputStream, ImageFormat.jpeg) End If End Sub </script> galeria.aspx: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <%@ Page Language="vb" ContentType="text/html" ResponseEncoding="iso-8859-1" Debug="True"%> <%@ Import Namespace="System.IO" %> <%@Import Namespace="System.Drawing.Imaging" %> <script Language="VB" runat="server"> Const maxWidth as Integer = 160 Const maxHeight as Integer = 120 Const nreg=6 Dim PathVar as String = Server.MapPath(".") + "\" '----------------------------------------------------------- Sub Page_Load(sender as Object, e as EventArgs) Dim images As Array ' Stores JPEG and dir from current directory Dim pics as ArrayList = new ArrayList() ' Datasource for the Image Gallery ' (each element is a set of html code [a String] ) Dim page As Integer ' Request.QueryString("page") or 1 Dim imgHeight, imgWidth as Integer ' The actual physical size of the image ' Two Variables that store the value of the directories the user clicks into Dim inSubpage as String = Request.QueryString("subpage") Dim inSubpageSlash as String = "" ' Step 1 - Process the inSubpage and generate the links for the "top" ASP.NET label HandleDirectoryInput(inSubpage, inSubpageSlash) ' Step 2 - Generate the array of the files in the current directory images = BuildImagesArray() ' Step 3 - Build the Prev, Page Info, and Next Links, Calculate # of Pages page = ProcessPageInput(inSubpage, images) ' Step 4 - Generate the code for each of the elements that will display Dim index As Integer For index = (page-1)*nreg to page*nreg-1 if index < images.length Dim s As String = images(index) ' Step 4.1 - The elements that will be added is a JPEG if s.ToUpper().IndexOf(".JPG") >= 0 pics.Add(AddImage(s, imgHeight, imgWidth, inSubpageSlash)) 'Step 4.2 - The elements that will be added is a directory link Else pics.Add(AddDirectoryLink(s, inSubpageSlash)) end if end if Next ' Step 5 - Standard DataSource Binding dlPictures.DataSource = pics dlPictures.DataBind() End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Function : HandleDirectoryInput ' ' ' ' Precondition : inSubpage has been set equal to Request.QueryString("subpage") ' ' Postcondition : the directory links displayed by the "top" ASP label is constructed ' ' inSubpageSlash is parsed so that is can be used later on the page ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub HandleDirectoryInput(inSubpage As String, ByRef inSubpageSlash As String) Dim used as String = "" Dim unused as String If inSubpage <> "" unused = inSubpage.replace(" ", "_") inSubpageSlash = inSubpage + "\" PathVar += inSubpageSlash While unused.IndexOf("\") > 0 used = inSubpage.subString(0,used.length + unused.IndexOf("\")).replace(" ", "_") unused = inSubpage.subString(used.length+1, inSubpage.length-used.length-1).replace(" ", "_") used += "\" End While End If End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Function : BuildImagesArray ' ' ' ' Precondition : ' ' Postcondition : takes the JPEG images and directories in target directory and ' ' puts them in the images Array. If nothing is returned, print error. ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function BuildImagesArray() As Array Dim images As Array Dim s as String, html as String Dim dirs As String() = Directory.GetDirectories(PathVar, "*") Dim files As String() = Directory.GetFiles(PathVar, "*.jpg") images = Array.CreateInstance(GetType(String), files.length + dirs.length) If dirs.length <> 0 AND files.length <> 0 dirs.copyTo(images,0) files.copyTo(images, dirs.length) Else If files.length <> 0 files.copyTo(images,0) Else If dirs.length <> 0 dirs.copyTo(images,0) Else Response.Write("No Content to Generate. Make sure you have images or sub-directories in the Source Directory") 'System.Exit() End If return images End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Function : ProcessPageInput ' ' ' ' Precondition : ' ' Postcondition : takes the QueryString("page") variable and calculate number of ' ' pages that the current gallery (dir) has - if no page variable is ' ' assigned, default to page = 1 ' ' build the "Prev Link, Page Info (Page # of #), and Next Link ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function ProcessPageInput(inSubpage As String, images As Array) As Integer Dim page As Integer if Request.QueryString("page") <> "" page = Request.QueryString("page") else page = 1 end if Dim index = 0 If page = 1 bottom.Text = "<th width=20%> </th>" Else bottom.Text = "<td align=center width=20%><font face='Verdana' size='1'> " _ &"<a href='default.aspx?page=" & (page-1) & "&subpage=" & inSubpage & "'><= Anterior</a></font></td>" End If Dim pages as Integer = 0 Dim num as Integer = images.length while num > 0 pages = pages + 1 num -= nreg end while Dim myto as Integer If page*nreg > images.length myto = images.length Else myto = page*nreg End If bottom.Text += "<td><center><font face='Verdana' size='1'>Pag. " & page & " of " & pages _ & "</font></center></td>" If page = pages bottom.Text += "<th width=20%> </th>" Else bottom.Text += "<td align=center width=20%><font face='Verdana' size='1'> " _ &"<a href='default.aspx?page=" & (page+1) & "&subpage=" & inSubpage & "'>Próximo =></a></font></td>" End If return page End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Function : AddImage ' ' ' ' Precondition : s (a string representing the full path and filename of the image) ' ' imgHeight and imgWidth are already calculated ' ' Postcondition : Generate code that displays the thumbnail link as a link to the ' ' full scale image that will be popped up in a window opened by a ' ' link created with JavaScript so that the window can be sized to fit ' ' the image. Also display some file info, size, name, etc... ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function AddImage(s As String, imgHeight As Integer, imgWidth As Integer, inSubpageSlash As String) As String Dim currentImage as System.Drawing.Image Try currentImage = System.Drawing.Image.FromFile(s) Catch exp as OutOfMemoryException Return "There was an error loading file information for " & _ Path.GetFileName(s) End Try DIM fs as FileStream = new FileStream(s, _ FileMode.Open, FileAccess.Read, FileShare.Read) ScaleFactorCalculations(imgHeight, imgWidth, currentImage) 'Dim filename = Path.GetFileNameWithoutExtension(s) Dim filename = Path.GetFileName(s) If filename.length > 20 filename = filename.substring(0,17) & "..." End If Dim size As new Integer size = fs.Length/1024 DIM PathVar2 = Path.GetFullPath(s.replace(" ","%20")) return "<a href=""javascript:NewWindow('" & inSubpageSlash.replace("\","/") & Path.GetFileName(s) & _ "','" & currentImage.Width & "','" & currentImage.Height & "')"">" & _ "<img src=""thu.aspx?img=" & Path.GetFileName(s.replace(" ","%20")) & "&w=" & _ imgWidth & "&h=" & imgHeight & "&path=" & PathVar.replace(" ", "%20") & """ border=0></a><br>" & _ "<div align=center><span style=""font size:'8pt'; font-family:'Verdana';"">" & filename & "<br>" & _ currentImage.Width & "x" & currentImage.Height & "<br>" & _ size & " KB<br></span></div>" End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Function : AddDirectoryLink ' ' ' ' Precondition : s (the full path of the directory we will be linking to) ' ' inSubpageSlash (the parsed value of QueryString("subpage")) ' ' Postcondition : Generate code that displays a picture of a folder (folder.gif) as a ' ' link to the directory that it will open. Also display some ' ' directory info, name, subdirectories contained, files contained ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Function AddDirectoryLink(s As String, inSubpageSlash As String) As String try Dim filesIn = Directory.GetFiles(s, "*.jpg") Dim dirsIn = Directory.GetDirectories(s) return "<a href=""default.aspx?page=1&subpage=" & inSubpageSlash.replace(" ","%20") & Path.GetFileName(s.replace(" ","%20")) & """><img width=125 height=93 src=""Folder.jpg"" border='0'></a><br>" _ & "<div align=center><span style=""font size:'8pt'; font-family:'Verdana';"">" & Path.GetFileName(s) & "<br>" & _ dirsIn.length & " directories<br>" & filesIn.length & " images<br></span></div>" catch Response.Write(s) end try End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Function : ScaleFactor Calculations ' ' ' ' Precondition : maxHeight and maxWidth are defined globally ' ' currentImage is a valid instance of a JPEG image ' ' Postcondition : a proper ScaleFactor has been calculated, and applied to the ' ' imgHeight and imgWidth variables. ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub ScaleFactorCalculations(ByRef imgHeight As Integer, ByRef imgWidth As Integer, currentImage as System.Drawing.Image) imgHeight = currentImage.Height imgWidth = currentImage.Width Dim scaleFactor as Double If imgWidth > maxWidth OR imgHeight > maxHeight then If (maxHeight / imgHeight) > (maxWidth / imgWidth) then scaleFactor = maxHeight / imgHeight Else scaleFactor = maxWidth / imgWidth End If End If If imgWidth > maxWidth then scaleFactor = maxWidth / imgWidth imgWidth *= scaleFactor imgHeight *= scaleFactor End If If imgHeight > maxHeight then imgWidth /= scaleFactor imgHeight /= scaleFactor scaleFactor = maxHeight / imgHeight imgWidth *= scaleFactor imgHeight *= scaleFactor End If End Sub '----------------------------------------------------------- </script> <script language="JavaScript"> function NewWindow(url, w, h) { // If you place default.aspx in a different directory that your root image directory, // you will need to add the image directory to url below, like: // url = "/rootImageDirectory/" + url + ".jpg" if (w > screen.width || h > screen.width) { if (w > screen.width && h <= screen.height) { var nw = screen.width - 70; var nh = parseInt(h) + 36 } if (h > screen.height && w <= screen.width) { var nh = screen.height - 70; var nw = parseInt(w) + 36 } if (w > screen.width && h > screen.height) { var nh = screen.height - 70; var nw = screen.width - 70; } window.open(url,"_blank","width=" + nw + ",height=" + nh + ",left=0,top=0,scrollbars=yes,resizable=yes"); } else { var nh = parseInt(h) + 25; var nw = parseInt(w) + 25; window.open(url,"_blank","width=" + nw + ",height=" + nh + ",scrollbars=no,resizable=no"); } } </script> <html> <head> <title>:: Circuito Vila Real - REVIVAL</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form runat="server"> <table> <tr> <td style="border-right: 1px solid #cccccc; padding: 10px;"> <table width="200" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td style="border: 1px solid black;"><img src="logo.gif" width="200" height="200"></td> </tr> </table> </td> <td> <table cellspacing=0 cellpadding=0 border=0 align="center"> <tr> <td colspan="3"> <asp:DataList runat="server" id="dlPictures" RepeatColumns="3" Font-Name="Verdana" Font-Size="8pt" CellSpacing="10" Item-BorderWidth="1" Item-BorderColor="#c0c0c0" BorderStyle="None" ItemStyle-Width="125" CellPadding="0" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Bottom" GridLines="Both" ItemStyle-BorderStyle="Solid"> <ItemTemplate> <table cellspacing=0 cellpadding=0 border=0 width=100% height=100% bgcolor=ffffff> <tr> <td onMouseOver="javascript:if (document.all) this.style.backgroundColor='#eeeeee';this.style.filter = 'alpha(opacity=100)'" onMouseOut="javascript:if (document.all) this.style.backgroundColor='#ffffff';this.style.filter = 'alpha(opacity=70)';" align="center"> <br><%# Container.DataItem %> </td> </tr> </table> </ItemTemplate> </asp:DataList> </td> </tr> <tr> <asp:label id="bottom" runat="server" /> </tr> </table> </td> </tr> </table> </form> </body> </html> |
estos dos ficheros los he cogido y los he copiado cada uno en un fichero distinto y los he metido en una carpeta... los he abierto con el dreamweaver, pero ... no se utilizarlo.... y con el Frontpage, me salen cosas raras..
¿como debo de utilizarlo ? saludos y gracias |
Tienes que tener el microsoft framework y IIS.
|
alguna plantilla sin necesidad de estas cosas, ¿en flash? o javascript o alguna cosa parecida?
gracias de todas formas jogo ;) |
La franja horaria es GMT +2. Ahora son las 02:28. |
Powered por vBulletin™ Version 3.8.10
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.
Traducido por vBsoporte - vBulletin en español
ZackYFileS - Foros de Debate