四海人民公摄 - 海外华人摄影爱好者论坛

 找回密码
 注册
搜索
热搜: 活动 交友 discuz
查看: 1190|回复: 0

phpThumb

[复制链接]
发表于 2010-1-21 10:40:24 | 显示全部楼层 |阅读模式
phpThumb, an image processing script, has been installed today. It allows us to reduce image size before sent to browser. This significantly reduce page loading time as smaller image is transfered when no big image is needed. the script also cache the processed files, imptoving the speed enven further.

The first application of this function is the conveyer belt image show on top of the home page. All images were downloaded in full size but reduced at the browser end wasting bandwidth. Now the images are resized before sent to the browser.


Here is the conveyer belt code:

  1. <script type="text/javascript">
  2. /***********************************************
  3. * Conveyor belt slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
  4. * This notice MUST stay intact for legal use
  5. * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
  6. ***********************************************/

  7. //Specify the slider's width (in pixels)
  8. var sliderwidth="1064px"
  9. //Specify the slider's height
  10. var sliderheight="90px"
  11. //Specify the slider's slide speed (larger is faster 1-10)
  12. var slidespeed=1
  13. //configure background color:
  14. slidebgcolor="#1E4B7E"
  15. //Specify the slider's images
  16. var leftrightslide=new Array()
  17. var finalslide=''
  18. [node]
  19. leftrightslide[{order}-1]='<a href={link} target=_blank> <img src=../phpthumb/phpThumb.php?src=../discuz/{imgfile}&h=80&fltr[]=usm|80|0.5|3 border=1 title="{subject} - {author}">     </a>'
  20. [/node]

  21. //Specify gap between each image (use HTML):
  22. var imagegap=" "
  23. //Specify pixels gap between each slideshow rotation (use integer):
  24. var slideshowgap=5

  25. ////NO NEED TO EDIT BELOW THIS LINE////////////
  26. var copyspeed=slidespeed
  27. leftrightslide='<nobr>'+leftrightslide.join(imagegap)+'</nobr>'
  28. var iedom=document.all||document.getElementById
  29. if (iedom)
  30. document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
  31. var actualwidth=''
  32. var cross_slide, ns_slide
  33. function fillup(){
  34. if (iedom){
  35. cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
  36. cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
  37. cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
  38. actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
  39. cross_slide2.style.left=actualwidth+slideshowgap+"px"
  40. }
  41. else if (document.layers){
  42. ns_slide=document.ns_slidemenu.document.ns_slidemenu2
  43. ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
  44. ns_slide.document.write(leftrightslide)
  45. ns_slide.document.close()
  46. actualwidth=ns_slide.document.width
  47. ns_slide2.left=actualwidth+slideshowgap
  48. ns_slide2.document.write(leftrightslide)
  49. ns_slide2.document.close()
  50. }
  51. lefttime=setInterval("slideleft()",30)
  52. }
  53. window.onload=fillup
  54. function slideleft(){
  55. if (iedom){
  56. if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
  57. cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
  58. else
  59. cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"
  60. if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
  61. cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
  62. else
  63. cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"
  64. }
  65. else if (document.layers){
  66. if (ns_slide.left>(actualwidth*(-1)+8))
  67. ns_slide.left-=copyspeed
  68. else
  69. ns_slide.left=ns_slide2.left+actualwidth+slideshowgap
  70. if (ns_slide2.left>(actualwidth*(-1)+8))
  71. ns_slide2.left-=copyspeed
  72. else
  73. ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
  74. }
  75. }

  76. if (iedom||document.layers){
  77. with (document){
  78. document.write('<table border="0" cellspacing="0" cellpadding="0"><td valign=middle>')
  79. if (iedom){
  80. write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
  81. write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
  82. write('<div id="test2" style="position:absolute;left:0px;top:10px"></div>')
  83. write('<div id="test3" style="position:absolute;left:-1000px;top:10px"></div>')
  84. write('</div></div>')
  85. }
  86. else if (document.layers){
  87. write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
  88. write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
  89. write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
  90. write('</ilayer>')
  91. }
  92. document.write('</td></table>')
  93. }
  94. }
  95. </script>
复制代码


In this code the image fetching part is changed from
  1. [node]
  2. leftrightslide[{order}-1]='<a href={link} target=_blank> <img height= 80 src={imgfile} border=1 title="{subject} - {author}"> </a>'
  3. [/node]
复制代码


to

  1. [node]
  2. leftrightslide[{order}-1]='<a href={link} target=_blank> <img src=../phpthumb/phpThumb.php?src=../discuz/{imgfile}&h=80&fltr[]=usm|80|0.5|3 border=1 title="{subject} - {author}">     </a>'
  3. [/node]
复制代码

Note, relative path is used here (it took a while to make this right).
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|四海人民公摄 - 海外华人摄影爱好者网站

GMT+8, 2024-11-22 01:32

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表