Back to PhocaGalleryPicasa class

Method getSize

public static
getSize
(mixed &$mediumT)

Method getSize - Source code

public static function getSize(&$mediumT)
{
    // If small and medium can be taken from $thumbSize, take it from here as these images can be cropped
    $thumbSize = array(32, 48, 64, 72, 104, 144, 150, 160);
    $imgMax = array(94, 110, 128, 200, 220, 288, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600);
    $paramsC = ComponentHelper::getParams('com_phocagallery');
    $lw = $paramsC->get('large_image_width', 640);
    $mw = $paramsC->get('medium_image_width', 256);
    $sw = $paramsC->get('small_image_width', 128);
    $crop = $paramsC->get('crop_thumbnail', 5);
    $output = array();
    $outputS = $outputM = $outputL = $outputLargeSize = '';
    // Large
    foreach ($imgMax as $value) {
        // First value which is greater than the large_image_width will be taken
        if ((int) $value > (int) $lw || (int) $value == (int) $lw) {
            $outputL = '&imgmax=' . (int) $value;
            $outputLargeSize = $value;
            break;
        }
    }
    // Small
    foreach ($thumbSize as $value) {
        // First value which is greater than the large_image_width will be taken
        if ((int) $value > (int) $sw || (int) $value == (int) $sw) {
            $outputS = '&thumbsize=' . (int) $value;
            break;
        }
    }
    // Medium
    // Try to handle it as thumbnail
    foreach ($thumbSize as $value) {
        // First value which is greater than the large_image_width will be taken
        if ((int) $value > (int) $mw || (int) $value == (int) $mw) {
            //$outputM		= '&thumbsize='.(int)$value;
            $outputM = ',' . (int) $value;
            $mediumT = 1;
            break;
        }
    }
    // Try to find it in imgmax
    if ($mediumT != 1) {
        foreach ($imgMax as $value) {
            // First value which is greater than the large_image_width will be taken
            if ((int) $value > (int) $mw || (int) $value == (int) $mw) {
                $outputM = '&imgmax=' . (int) $value;
                $mediumT = 0;
                break;
            }
        }
    }
    // Small Crop
    if ($crop == 3 || $crop == 5 || $crop == 6 || $crop == 7) {
        $outputS = $outputS . 'c';
    } else {
        $outputS = $outputS . 'u';
    }
    // Medium Crop
    if ($mediumT == 1) {
        if ($crop == 2 || $crop == 4 || $crop == 5 || $crop == 7) {
            $outputM = $outputM . 'c';
        } else {
            $outputM = $outputM . 'u';
        }
    }
    if ($mediumT == 1) {
        $output['lsm'] = $outputL . $outputS . $outputM;
    } else {
        $output['lsm'] = $outputL . $outputS;
    }
    if ($mediumT != 1) {
        $output['m'] = $outputM;
    }
    // This we need for getting info about size and and removing this size to get an original image
    // It is not lsm
    $output['ls'] = $outputLargeSize;
    return $output;
}