I am retrieving album photos from facebook's graph api.
This code does the trick, however i am trying to select the smallest thumbnail that equal 130 and above width:130 x height:130
meaning the width OR height has to be 130 and above, NOT the sum of width and height.
note: the array list are image variation from facebooks album, so they would be in proportion. so if it is a portrait or landscape dimension it would scale in dimension accordingly.
So from the print_r below you can see the in the first array, item (2) fits that description, but the other arrays would be numbers (2) and (1) since this is the smallest above 130 width/height
$userURL2 = "https://graph.facebook.com/$albumID/photos?access_token=" . $fb_oAuth_token;
$ch2 = curl_init($userURL2);
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
$data2 = curl_exec($ch2);
curl_close($ch2);
$pictures = json_decode($data2, true);
print_r($pictures);
output from print_r($pictures);
Array
(
[0] => Array
(
[height] => 288
[width] => 460
[source] => https://myurl.jpg
)
[1] => Array
(
[height] => 200
[width] => 320
[source] => https://myurl.jpg
)
[2] => Array
(
[height] => 130
[width] => 180
[source] => https://myurl.jpg
)
[3] => Array
(
[height] => 81
[width] => 130
[source] => https://myurl.jpg
)
)
Array
(
[0] => Array
(
[height] => 500
[width] => 500
[source] => https://myurl.jpg
)
[1] => Array
(
[height] => 500
[width] => 500
[source] => https://myurl.jpg
)
[2] => Array
(
[height] => 480
[width] => 480
[source] => https://myurl.jpg
)
)
Array
(
[0] => Array
(
[height] => 335
[width] => 300
[source] => https://myurl.jpg
)
[1] => Array
(
[height] => 335
[width] => 300
[source] => https://myurl.jpg
)
)
question: How would i write this in php?
foreach($pictures['data'] as $picture){
$width = $picture['width'];
$height = $picture['height'];
// choose the smallest [source] above width:130 x height:130
}