News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Flickr Viewer

Started by baptie, October 22, 2010, 07:56:55 AM

Previous topic - Next topic

baptie

Hi,

I have installed and used the Flickr mod on the site and it works really well on a personal level.
I am admin for a mini owners club that use flickr as there image storing site.

I used this mod:
http://custom.simplemachines.org/mods/index.php?mod=1564

The mod is coded to view sets and not groups, this can be modified but I am only a beginner at PHP.

I was wondering if anyone could offer there PHP knowlege to alter code to group viewr and not sets?

Example of group code: http://phpflickr.com/examples/a-users-groups/source/

PJLawrence

Hi,
If you look at the file flickrgallerybrowser.php in the flickr mod code the two key functions which will require modifications for group display are...

function getSets($person,$f) ...this gets the set list for a given person ....
function getFlickrPhotos($person,$f,$photoset_id,$title) ... which gets the list of photos in a user's set.

Lets take a closer look at the getFlickrPhotos function which gets the list of photos from a given set and displays the thumbnail images.
The first line uses the phpflickr command to get this list.

$setphotos = $f->photosets_getPhotos($photoset_id, NULL, NULL);

As a start you could try to hard code this, for testing, by replacing this instruction with the equivalent group command groups_pools_getPhotos
try something like this..

$groups = $f->people_getPublicGroups($person['id']);
$setphotos = $f->groups_pools_getPhotos($groups[0]['nsid']);


This should force the mod to display the first photo group when you select to view a person set in smf.
If this works let me know and then we can discuss how to get a thumb nail photo list of all the groups a person belongs to, or what ever your requirements are.



baptie

Gave it a try, Kept getting errors!
Mind I don't really know how to test the Mod on its own.

Altered the code and got error:
Fatal error: require_once() [function.require]: Failed opening required 'phpFlickr/phpFlickr.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/*******/public_html/forum/Sources/flickrgallerybrowser.php on line 12

Little bit above my skill level at the moment, even with the use of first page.

thanks for advice.

PJLawrence

Hi, this error message does not seem to be related to the lines of code you've change but the script not being able to find the phpFlickr.php file in the subfolder phpFlickr in your Source folder.

baptie

As I say dude, its all a bit above my skill level at the moment.

Thanks for the advice.

PJLawrence

With a little bit more effort I think we might be able to solve this problem.
Try this, first install the mod as normal and then edit the file flickrgallerybrowser.php file found in the Source folder of your smf forum.

Then replace the function getSets($person,$f) with the following code...


function getSets($person,$f)
{
    $groups = $f->people_getPublicGroups($person['id']);
    $sets = array();
    $i=0;
    for ( $i = 0; $i < count($groups); $i++ )
    {
        $photos_getInfo = $f->groups_pools_getPhotos($groups[$i]['nsid']);
        $photos = $f->groups_pools_getPhotos($groups[$i]['nsid'], NULL, NULL, NULL, 1);

        foreach ((array)$photos['photo'] as $photo) {
            $row = array();
            $row['id'] = $i;
            $row['title'] = $groups[$i]['name'] ;
            $row['description'] = '';
            $row['thumbnail'] = $f->buildPhotoURL($photo, "Square");
            $row['slug'] = $i+1;
            $sets[$i] = $row;
       }
   }
   return $sets;
}


...and then replace the function getFlickrPhotos($person,$f,$photoset_id,$title)  with this code

function getFlickrPhotos($person,$f,$photoset_id,$title)
{
       $MaxImages=10;
       $groups = $f->people_getPublicGroups($person['id']);
       $setphotos = $f->groups_pools_getPhotos($groups[$photoset_id-1]['nsid'], NULL, NULL, NULL, $MaxImages);

$photos = array();
$i = 0;
foreach ((array)$setphotos['photo'] as $photo)
{
$info = $f->photos_getInfo($photo['id']);
$image_size=$f->photos_getSizes($photo['id']);
$row = array();
$row['id'] = $i;
$row['gid'] = $photo['id'];
$row['title'] = $photo['title'];
$row['height'] = $image_size[4]['height'];
$row['width'] = $image_size[4]['width'];
$row['size'] = '10'; //round($photo['gphoto']['size']/102.40)/10.0;
$row['timestamp'] = $info['dates']['posted'];// lastupdate
$row['taken'] = $info['dates']['taken'];
$row['description'] = $info['description'];
$row['thumbnail72'] = $f->buildPhotoURL($photo, "square");
$row['thumbnail144'] = $f->buildPhotoURL($photo, "thumbnail");
$row['thumbnail288'] = $f->buildPhotoURL($photo, "small");
$row['url'] = $f->buildPhotoURL($photo, "medium");

$photos[$i] = $row;
$i++;
}
return $photos;
}



baptie

Updated flickrgallerybrowser.php with the above code snippets.

it crashed.
came up with diagnose problem window.

Also with live testing I have ended up with duplicate 'flickr group' buttons on the header tool bar.



Thanks for efforts Dude.

PJLawrence

Baptie it looks like you have installed the mod twice. Check in your package set up. If this is the case then to remove the double header you should uninstall the flickr mods in reverse order in which you have installed them. If not let me know since you'll need to remove the menu items manually.
What set up are you using for testing?

baptie

I used mod version 4, altered flickrgallerybrowser.php and tested live on the club forum.

after every test I remove the mod, I have now got 3 extra flickr mod's on the button header and no flickr mod installed.

uninstalling using the package toolbar

PJLawrence

Did the package manager report any problems with the uninstall?
Anyway, you'll need to remove the menu items by editing your /Sources/Subs.php file for SMF2 or
./Themes/default/index.template.php in smf1.

PJLawrence

Just to add to my last post. If you want to see what code to delete simply go to the mod page
http://custom.simplemachines.org/mods/index.php?mod=1564
select your version of smf, see right hand box, and then select the parse button.
Then scroll down to the file, for your version, I referred to in my last post. Then delete the code it lists in the "add after" section.

baptie

got the extra buttons off.

Found them in index.template.php

cheers dude

PJLawrence

Good to see you got that problem sorted. Regarding my other question what test system are you using? Since it shouldn't crash if there is an error in the php code the only problem would be that the page does not load correctly and you get a php error message.

Do you want to continue with this? Since it's a request that has often been asked for. However, since it's something I'll not be using myself it would be difficult for me to support. So once developed I would be looking for someone to refine it further and adopt this as a mod.

Also when I was testing out the modified code for group photo browsing I noticed that if you download a lot of images it would time out. So a further development that would be required is for the ability for paging through the images. Again this is not difficult but would require time and effort.

baptie

This was initially a mod request, if it is not a worth while mod then it would be better leaving it.

I just didn't know how easy/hard it was to modify the code to highlight groups.
I just know its a lot of work modifying 5 years worth of uploaded images from groups format to sets.

Just thought it would give a fresh outlook to the tired forum.

As above, many thanks for your time and efforts.

PJLawrence

#14
Attached is a beta version 0.5 of the flickr mod which should allow group browsing.
This test version allows the user to switch between viewing sets or groups, via the admin options
One problem is that if a user is a member of a lot of groups the group browsing page can be rather slow or time out.

Note this is a test version and shouldn't be deployed outside a test environment. I'm posting it here for beta testing and for feedback regarding whether this is worth developing further.

On the 26th November I removed the attachment from this post, since a new version of the mod 0.6 is now available to download. Version 0.6 support groups, plus the ability to page through sets, groups and photos.

PJLawrence

Also note there is an alternative method to include group images in your forum, see topic..
Embed Flickr

baptie

You are some guy, you really are.

Heres another.......is there a way to get a list to ALL groups and not just a single group?
As we have at the moment 46 groups and zero sets.

Followed your like no iframe, Like your style!

I think once I get to grips with the groups on the forum I may even add a iframe to the webpage.
Just tested iframe offline with my personal photstream and it worked a charm.

mucho danka dude!

PJLawrence

I've had a quick look to see if it's possible to get a list of group/set using iframes. However, I didn't find a solution.
Have you had any luck?
Version 0.6 of the flickr gallery mod is now available. This new version supports groups, plus the ability to page through sets, groups and photos.

baptie

Looked for a couple of nights but couldn't come up with a global group method.
it would be ideal if it was possible as we have 1000's of images spanning 4-5 years, great to scroll through.

I made a group of 20 images but its kinda boring watching the same 20 if you know what i mean!

baptie

me again........

Is it possible to have the mod actually on the front page?
I have been looking at possibly adding an iframe to the front page but was unsure where to add just incasey I broke the forum  :-[

<div align="center"><iframe src="http://www.flickr.com/slideShow/index.gne?user_id=42496656@N00" frameBorder="0" width="300" scrolling="no" height="300"></iframe>
</div>

Advertisement: