I have my Full Size Image width set for 800. The problem happens when a flickr image does not have a size with the suffix "_b.jpg" even though the orginal size "_o.jpg" is good enough to be scaled down. Because of this the image displays (This Photo is Currently Unavailable)
I am sure this "_b.jpg" is hardcoded somewhere in the module, but it first needs to see what sizes are available before automatically appending "_b.jpg"
**Update: I look into the code, the problem is in the function _image_ncck_flickr_guess_size
its is guessing instead of using the flickr.photos.getSizes
**Update: Ok, after figuring it out I have redone the function image_ncck_flickr_image_url to completely work off of the flickr.photos.getSizes instead of getInfo and changed the _image_ncck_flickr_guess_size to be the numbers in the ['sizes'] array instead of the s,t,m,o,b
The new functions to replace the old ones:
function image_ncck_flickr_image_url($code, $width, $height, $formatter = NULL, $field = NULL, $item = NULL, $node = NULL) {
if ($code) {
$size = _image_ncck_flickr_guess_size($width, $height);
$getsize = image_ncck_flickr_request('flickr.photos.getSizes', array('photo_id' => $code));
$url = $getsize['sizes']['size'][$size]['source'];
}
return $url;
}
function _image_ncck_flickr_guess_size($width, $height) {
$max = max($width, $height);
foreach (array('0' => 75, '1' => 100, '2' => 240, '3' => 500, '4' => 1024) as $size => $value) {
if ($max <= $value) {
return $size;
}
}
return '5';
}
http://www.flickr.com/services/api/flickr.photos.getSizes.html
The code is going to need some cleaning, ex: removing all the url constructing functions, (the getSize spits out the url by itself)
Future Problem
if the size is over 1024 but only has 5 elements in the array -> I would just count($getsize['sizes']['size']) and see if it is 5 than original is now [4] instead of [5], I have had no problems without this counting, but just thinking ahead.
Comments
Comment #1
aaron commentedThanks, coldice4678, works as advertised. Committed to d6 version. Needs to be ported to d5.
Comment #2
aaron commentedfinally go around to committing this to d5. Thanks, @coldice4678!