You are here

function _media_flickr_guess_size in Media: Flickr 7.2

Same name and namespace in other branches
  1. 7 includes/media_flickr.utilities.inc \_media_flickr_guess_size()

This will return the appropriate array key for the image size we wish.

Parameters

int $height:

int $width:

Return value

int

2 calls to _media_flickr_guess_size()
MediaFlickrUtils::testGuessSize in tests/MediaFlickrUtils.test
Test _media_flickr_guess_size().
_media_flickr_photo_url in includes/media_flickr.utilities.inc
Based on the Photo ID of a Flickr image, this will return the URL to the image itself.

File

includes/media_flickr.utilities.inc, line 136
Utility functions for Media: Flickr.

Code

function _media_flickr_guess_size($width = 0, $height = 0) {
  $max = max($width, $height);
  if ($max) {
    foreach (array(
      '0' => 75,
      '1' => 100,
      '2' => 240,
      '3' => 500,
      '4' => 1024,
    ) as $size => $value) {
      if ($max <= $value) {
        return $size;
      }
    }
  }

  // If we don't have width or height set, then get the original size.
  return NULL;
}