Categories
>> 楚水驿站-Freesky > 电脑程序
2006年8月21日
Lightbox v2.0 添加方法
  Lightbox是一个很流行的网页图片效果,尤其在图片会自动缩小为缩略图时尤其实用。
  具体效果可见:http://www.huddletogether.com/projects/lightbox2/
  程序下载地址:http://www.huddletogether.com/projects/lightbox2/lightbox2.02.zip
  现将具体步骤说明如下:
  首先下载Lightbox 2.02
  解压缩后得到css、images、js三个目录以及index.htm文件,其中index.htm是演示和说明文档。
  1. 在Z-Blog目录下的IMAGE里新建一个lightbox目录,将images内除了image-1.jpg和thumb-1.jpg以外的文件都上传进去。
  2. 用文本编辑器打开js目录下的lightbox.js文件,修改如下:
  查找替换字符串 images/ ,修改为http://URL/IMAGE/lightbox/ 记住一定要加上 /。
  3. 用文本编辑器打开css目录下的lightbox.css文件,查找替换 ../images/ 为http://URL/IMAGE/lightbox/ 同样记住一定要加上 / 。
  4. 将lightbox.css上传到Z-Blog目录的CSS目录下。
  5. 将js目录下所有文件上传到Z-Blog目录的SCRIPT目录下。
  6. 修改Z-Blog目录/FUNCTION/c_function.asp文件,在728行处开始。
  原代码:

                objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<img src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")

                objRegExp.Pattern="(\[IMG=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<img src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")

                objRegExp.Pattern="(\[IMG=)([0-9]*)(\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<img src=""$4"" alt="""" title="""" width=""$2""/>")

                objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" src=""$2"" alt="""" title=""""/>")


                objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")

                objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")

                objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*)(\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$4"" alt="""" title="""" width=""$2""/>")

                objRegExp.Pattern="(\[IMG_LEFT\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-left"" style=""float:left"" src=""$2"" alt="""" title=""""/>")


                objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")

                objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")

                objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*)(\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$4"" alt="""" title="""" width=""$2""/>")

                objRegExp.Pattern="(\[IMG_RIGHT\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-right"" style=""float:right"" src=""$2"" alt="""" title=""""/>")

  修改为:


                objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$6"" rel=""lightbox"" title=""$4""><img src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/></a>")

                objRegExp.Pattern="(\[IMG=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$5"" rel=""lightbox"" title=""$3""><img src=""$5"" alt=""$3"" title=""$3"" width=""$2""/></a>")

                objRegExp.Pattern="(\[IMG=)([0-9]*)(\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$4"" rel=""lightbox"" title=""""><img src=""$4"" alt="""" title="""" width=""$2""/></a>")

                objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$2"" rel=""lightbox"" title=""""><img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" src=""$2"" alt="""" title=""""/></a>")


                objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$6"" rel=""lightbox"" title=""$4""><img class=""float-left"" style=""float:left"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/></a>")

                objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$5"" rel=""lightbox"" title=""$3""><img class=""float-left"" style=""float:left"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/></a>")

                objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*)(\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$4"" rel=""lightbox"" title=""""><img class=""float-left"" style=""float:left"" src=""$4"" alt="""" title="""" width=""$2""/></a>")

                objRegExp.Pattern="(\[IMG_LEFT\])(.+?)(\[\/IMG_LEFT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$2"" rel=""lightbox"" title=""""><img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-left"" style=""float:left"" src=""$2"" alt="""" title=""""/></a>")


                objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$6"" rel=""lightbox"" title=""$4""><img class=""float-right"" style=""float:right"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/></a>")

                objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$5"" rel=""lightbox"" title=""$3""><img class=""float-right"" style=""float:right"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/></a>")

                objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*)(\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$4"" rel=""lightbox"" title=""""><img class=""float-right"" style=""float:right"" src=""$4"" alt="""" title="""" width=""$2""/></a>")

                objRegExp.Pattern="(\[IMG_RIGHT\])(.+?)(\[\/IMG_RIGHT\])"
                strContent= objRegExp.Replace(strContent,"<a href=""$2"" rel=""lightbox"" title=""""><img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-right"" style=""float:right"" src=""$2"" alt="""" title=""""/></a>")

  修改完毕保存。
  7. 打开Z-Blog目录/TEMPLATE/single.html文件,在和之间加上如下代码:

        <script type="text/javascript" src="http://freeskyblog.com/SCRIPT/prototype.js"></script>
        <script type="text/javascript" src="http://freeskyblog.com/SCRIPT/scriptaculous.js?load=effects"></script>
        <script type="text/javascript" src="http://freeskyblog.com/SCRIPT/lightbox.js"></script>
        <link rel="stylesheet" href="http://freeskyblog.com/CSS/lightbox.css" type="text/css" media="screen" />


  8. 同样地修改search.html catalog.html 三个文件,保存。
  9. 修改Z-Blog目录/SCRIPT/common.js文件,删除末尾的:

       objImage.attachEvent('onclick', function(){try{showModelessDialog(objImage.src);}catch(e){window.open(objImage.src);}});

  10.

<body onload="initLightbox()">

* 温情提示:选择内容即可分享到您的腾讯微博

关于  Blog   的相关文章

一共有 4 条评论

Gravatar Icon
1# z1yq2006-9-4 23:50:04
请问 <body onload="initLightbox()"> 在那个页面添加啊?
引用  |  回复
Gravatar Icon
2# freesky2006-9-5 0:12:25
我在single.html、tags.html、search.html、catalog.html均加了,default.html没加。
引用  |  回复
Gravatar Icon
3# 死鱼2006-9-9 2:24:21
你这个模板的评论框框颜色怎么是白色的?都看不见了,怎么改啊?我的和你的一样~
引用  |  回复
Gravatar Icon
4# hanhao2006-10-26 21:08:46
引自 死鱼
你这个模板的评论框框颜色怎么是白色的?都看不见了,怎么改啊?我的和你的一样~

倒,在css里面改呀
引用  |  回复