Esempio n. 1
0
/**
 * Works out what size a requested image should be, based on request parameters
 *
 * The result of this function can be passed to get_dataroot_image_path to 
 * retrieve the filesystem path of the appropriate image
 */
function get_imagesize_parameters($sizeparam = 'size', $widthparam = 'width', $heightparam = 'height', $maxsizeparam = 'maxsize', $maxwidthparam = 'maxwidth', $maxheightparam = 'maxheight')
{
    $size = param_imagesize($sizeparam, '');
    $width = param_integer($widthparam, 0);
    $height = param_integer($heightparam, 0);
    $maxsize = param_integer($maxsizeparam, 0);
    $maxwidth = param_integer($maxwidthparam, 0);
    $maxheight = param_integer($maxheightparam, 0);
    return imagesize_data_to_internal_form($size, $width, $height, $maxsize, $maxwidth, $maxheight);
}
Esempio n. 2
0
 /**
  * Helper method
  */
 private function get_size_from_options($options)
 {
     $prefix = '';
     foreach (array('size', 'width', 'height', 'maxsize', 'maxwidth', 'maxheight') as $param) {
         if (isset($options[$param])) {
             ${$param} = $options[$param];
             $prefix .= $param . '-' . $options[$param] . '-';
         } else {
             ${$param} = null;
         }
     }
     return array(imagesize_data_to_internal_form($size, $width, $height, $maxsize, $maxwidth, $maxheight), $prefix);
 }