Scalable Photo Gallery

Scalable Photo Gallery

Hello,

I created my previous portfolio site entirely in AS3. You can see it here http://www.ryanwhittierhale.com/. I've decided to ditch Flash and remake my site using jQuery. Right now I have a mock up, but I'm running into problems with the scalable photo gallery. So far it scales correctly, but I can't figure out how to create a click through gallery. Ideally I would like to add Next and Previous buttons on the page to navigate the gallery.



Is there some way I could do something like??
  1. <img src= "img/"+img#+".jpg" width=img.width height=img.height /></p>
  2. onclick, img# = = "img#+1



Here is the image scaling script
  1. (function($) {
  2. $.fn.imagefit = function(options) {
  3. var fit = {
  4. all : function(imgs){
  5. imgs.each(function(){
  6. fit.one(this);
  7. })
  8. },
  9. one : function(img){
  10. $(img)
  11. .width('100%').each(function()
  12. {
  13. $(this).height(Math.round(
  14. $(this).attr('startheight')*($(this).width()/$(this).attr('startwidth')))
  15. );
  16. })
  17. }
  18. };
  19. this.each(function(){
  20. var container = this;
  21. // store list of contained images (excluding those in tables)
  22. var imgs = $('img', container).not($("table img"));
  23. // store initial dimensions on each image 
  24. imgs.each(function(){
  25. $(this).attr('startwidth', $(this).width())
  26. .attr('startheight', $(this).height())
  27. .css('max-width', $(this).attr('startwidth')+"px");
  28. fit.one(this);
  29. });
  30. // Re-adjust when window width is changed
  31. $(window).bind('resize', function(){
  32. fit.all(imgs);
  33. });
  34. });
  35. return this;
  36. };
  37. })(jQuery);



Here is the HTML Code
  1. <head>
  2. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  3. <title>Ryan Whittier Hale</title>
  4. <style type="text/css">
  5. body {
  6. <!--overflow:hidden;-->
  7. background-image: url("bg.jpg");
  8.    background-repeat: no-repeat;
  9. font-family: verdana, sans;
  10. font-size: 75%;
  11. background-color: #fff;
  12. color: #000;
  13. padding: 0;
  14. margin: 0;
  15. }
  16. p {margin: 0em 0;}
  17. div > p {
  18. margin-top: 0;
  19. }
  20. div#one, div#two {
  21. margin: 0 1%;
  22. float: left;
  23. }
  24. #one {width: 112px}
  25. #two {width: 78%}
  26. div.head {
  27. padding: 1em 1%;
  28. }
  29. </style>
  30. <script type="text/javascript" src="jquery.js"></script>
  31. <script type="text/javascript" src="jquery.imagefit.js"></script>
  32. <script type='text/javascript' src='script/jquery.cycle.all.js'></script>
  33. <script type="text/javascript">
  34. $(window).load(function(){
  35. $('#two').imagefit();
  36. });
  37.  
  38. $(document).ready(function(){ 
  39. $('#s1').cycle({
  40. fx:'fade',
  41. speed:'2000', 
  42. timeout: 0, 
  43. next:'#next', prev:'#prev'});
  44. });

  45.  
  46. </script>
  47. </head>
  48. <body>
  49. <div class="head">

  50. <!--<h1>JavaScript to proportionally scale images to fit.</h1> -->

  51. </div>
  52. <div id="one">
  53. <p>
  54. <p>Ryan Whittier Hale
  55. <br>
  56. <br>
  57. <p>Scenery
  58. <p>Hallway Lurker
  59. <p>Poser
  60. <p>Collage
  61. <p>Video
  62. <br>
  63. <br>
  64. <p>News
  65. <p>Contact/ CV
  66. <p>Links
  67. </p>
  68. </div>

  69. <div id="two">
  70. <p><img src="http://farm5.static.flickr.com/4032/4397661280_2645b9e917_b.jpg" width="1024" height="752" /></p>
  71. <br>
  72. <p>Body Harvest - digital-c print mounted on plexiglas - 30"x22" - ed. 1-8
  73. <p>©2010 - This image is protected by Federal copyright law
  74. </p>
  75. </div>

  76. </body>
  77. </html>