dfgallery 2.0: Flickr “this photo is currently unavailable” [SOLVED]
Introduction
A few days ago I talked about dfgallery 2.0 and some issues during the install process.
Well, I linked dfgallery with my flickr to view my photos in this website and noticed that some images were not displayed correctly. I saw the thumbs in the bottom, but not the full-size images. Instead a “this photo is currently unavailable” message appeared, with the flickr logo in the bottom.
I was pretty sure this had to do with dfgallery trying to load the “Large” size off flickr. However, Flickr only creates a large size when the file is above 1024×768 px. So there might be a way to get dfgallery to grab the “Original” size only…
The solution
I came to this solution after some time looking at the code. You have to follow this steps:
1. Change the code in <$path-to-dfgallery>\app\libraries\Album_Manager.php
2. Locate the
1 | class CI_Album_Manager |
3. Add the following function:
1 2 3 4 5 6 7 8 9 10 | // Added by Miguel Martín 2009-10-06 to solve the "This photo is currently unavailable" issue with flickr // albums function flickr_get_sizes($photo_id){ $sizes=array(); $p_sizes=$this->_flickr_api_invoke('flickr.photos.getSizes',array("photo_id"=>$photo_id)); foreach ($p_sizes['sizes']['size'] as $z) { $size[$z['label']] = array('width' => $z['width'], 'height' => $z['height'], 'source' => $z['source']); } return $size; } |
4. Now locate this function:
function process_album_flickr_set($album,$photoset_id,$max_size = '_b')
5. Change it for (just copy-paste):
function process_album_flickr_set($album,$photoset_id,$max_size = '_b') { $photoset = $this->_flickr_api_invoke('flickr.photosets.getInfo',array('photoset_id'=>$photoset_id)); $photoset = $photoset['photoset']; if (intval($photoset['photos'])>0){ $album->properties->set('title',$photoset['title']['_content'],FALSE); $album->properties->set('description',$photoset['description']['_content'],FALSE); $album->properties->set('icon',"http://farm$photoset[farm].static.flickr.com/$photoset[server]/$photoset[primary]_$photoset[secret]_s.jpg",FALSE); $album->properties->set('exif-type','none',FALSE); $current_page = 0; $per_page = 5; $total_pages = ceil($photoset['photos']/$per_page); $getPhotos_params = array('photoset_id'=>$photoset_id,'extras'=>'date_upload','per_page'=>'5','page'=>$current_page); $pages = array(); while ($current_page<$total_pages){ $getPhotos_params['page'] = ++$current_page; $pages[] = $this->_flickr_api_invoke('flickr.photosets.getPhotos',$getPhotos_params); } $album->images = array(); foreach($pages as $page){ if (is_array($page['photoset']['photo'])){ foreach ($page['photoset']['photo'] as $photo) { // the following line is new. Added by Miguel Martin $im_s=$this->flickr_get_sizes($photo['id']); $image = array(); $image['id'] = $photo['id']; $image['title'] = $photo['title']; $image['timestamp'] = $photo['dateupload']; //$image['thumbnail'] = "http://farm$photo[farm].static.flickr.com/$photo[server]/$photo[id]_$photo[secret]_s.jpg"; //$image['image'] = "http://farm$photo[farm].static.flickr.com/$photo[server]/$photo[id]_$photo[secret]$max_size.jpg"; $image['thumbnail'] = $im_s['Square']['source']; $image['image'] = $im_s['Large']['source']; $album->images[] = $image; } } } return $album; } return FALSE; }
This fix should solve all your problems!
If you prefer you can download the modified Album_Manager.php and replace yours.
Related posts:
Thanks, It worked perfect in my case.
Thanks for this solution
Throwing IOError in my case.
I have tried copying the code snippet as well as the whole file.
I’ve got the same error:-(
I tried this and it worked. But then when I added a new image to flickr the new image is doing it again and the solution doesn’t help. Any thoughts?
Hey, looks exactly like what I need, but I use the module flickr_highslide fpr joomla. Do you think it´s possible to change the flickr problem in flickr? Because I have no idea where to put your changed function in my module.
hello,
how resize thumbs ? Which variables an where decide for this /
Thanks in advice
Makaron
Yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeees!!!!!!!!!!!!!!!
Thank you so much!!!!