Flickr Photo Slideshow Integration
Hello —
My goal is to create a flickr slideshow gallery, but in more of a filmstrip form, that slides forward and backwards. Also using some descriptions under each photo. The idea is to create something that the client can interact with the Flickr Interface on the backend, but simultaneously be updating the homepage of their website.
The website is built with WordPress, so I can use phpFlickr to grab a photoset or a specific user's photos. I've done that within the main page of the site with the following code:
- <div id="slider" class="clear-block"><div id="slider-inner">
- <?php
- require_once("scripts/phpFlickr.php");
- // Create new phpFlickr object
- $f = new phpFlickr("7b0f2d2463bc56d47253a317db29e512");
-
- $i = 0;
-
- // Find the NSID of the username inputted via the form
- $person = $f->people_findByUsername(gregmihalko);
-
- // Get the friendly URL of the user's photos
- $photos_url = $f->urls_getUserPhotos($person['id']);
-
- // Get the user's first 36 public photos
- $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, 36);
-
- // Loop through the photos and output the html
- foreach ((array)$photos['photos']['photo'] as $photo) {
- //echo "<a href=$photos_url$photo[id]>";
- echo "<div class='image-node'><div class='image-img'><img border='0' class='imagefield imagefield-field_image_large' alt='$photo[title]' ".
- "src=" . $f->buildPhotoURL($photo, "Small") . ">";
- echo "</div></div>";
- $i++;
- // If it reaches the sixth photo, insert a line break
- if ($i % 6 == 0) {
- echo "<br>\n";
- }
- }
-
- ?>
- </div> </div> </div>
-
- <div id="slider-nav"><a href="javascript:void(0);" onclick="prev();" class="prev-image">« prev</a> | <a href="javascript:void(0);" onclick="next();" class="next-image">next »</a></div><div id="slider-caption-wrapper"><div id="slider-caption"></div></div>
The header is pulling in the following files (attached):
- <script type="text/javascript" src="test/scripts/jquery.js"></script>
- <script type="text/javascript" src="test/scripts/compat.js"></script>
- <script type="text/javascript" src="test/scripts/slider.js"></script>
Slider.js should be doing all of the work for me and I've tagged the divs and images correctly in the generated code.... (slider.js file below):
- var imgs;
- var totalWidth = 0;
- var index = 0;
- var count = 0;
- var margin = 10;
- var leftEdge = 0;
- $(document).ready(function() {
- var height = 0;
- imgs = $('#slider img');
- $(imgs).each(function(i){
- $(this).parents(".image-node").css({'width':parseInt(this.width)});
- });
- count = imgs.length;
- slide();
- })
-
- function next(){
- $("#slider-caption").hide();
- if(index >= count-1){
- index = 0;
- leftEdge = 0;
- slide();
- return true;
- };
- leftEdge -= parseInt(imgs[index].width)+margin;
- index++;
- slide();
- return true;
- }
- function prev(){
- $("#slider-caption").hide();
- if(index <= 0){
- index = 0;
- return true;
- }
- index--;
- leftEdge += parseInt(imgs[index].width)+margin;
- slide();
- return true;
- }
-
- function slide(){
- var text = $(imgs[index]).parents(".image-node").children(".image-teaser").html();
- $("#slider-caption").css({'width':parseInt(imgs[index].width)});
- $("#slider-caption").html(text);
- $('#slider-inner').animate({'left':leftEdge+245});
- $("#slider-caption").fadeIn("slow");
- }
Visit
http://communities-rising.org/test to see where I have gotten on it and maybe that will show you sort of what I'm going for. Any help is much appreciated and would be credited on the site if you can get it to work properly.