$derivative)
{
if ($type==IMG_SQUARE || $type==IMG_THUMB)
continue;
if (!array_key_exists($type, ImageStdParams::get_defined_type_map()))
continue;
$url = $derivative->get_url();
if (isset($added[$url]))
continue;
$added[$url] = 1;
$show_original &= !($derivative->same_as_source());
$unique_derivatives[$type]= $derivative;
if (isset($_COOKIE['available_size']))
{
$available_size = explode('x', $_COOKIE['available_size']);
$size = $derivative->get_size();
if ($size)
{
// echo $type.' => '.$size[0].' x '.$size[1].'
';
if ($size[0] <= $available_size[0] and $size[1] <= $available_size[1])
{
$automatic_size = $type;
}
}
}
}
global $page, $template;
load_language('plugin.lang', ASIZE_PATH);
$template->set_prefilter('picture', 'asize_picture_prefilter');
$is_automatic_size = true;
if (@$_COOKIE['is_automatic_size'] == 'no')
{
$is_automatic_size = false;
}
$template->assign(
array(
'is_automatic_size' => $is_automatic_size,
'ASIZE_URL' => duplicate_picture_url(),
)
);
if (isset($automatic_size))
{
if ($is_automatic_size)
{
$selected_derivative = $element_info['derivatives'][$automatic_size];
}
$template->assign(
array(
'automatic_size' => $automatic_size,
'ASIZE_TITLE' => sprintf(
l10n('The best adapted size for this photo and your screen is size %s'),
l10n($automatic_size)
)
)
);
}
if ($show_original)
{
$template->assign( 'U_ORIGINAL', $element_info['element_url'] );
}
$template->append('current', array(
'selected_derivative' => $selected_derivative,
'unique_derivatives' => $unique_derivatives,
), true);
$template->set_filenames(
array('default_content'=>'picture_content.tpl')
);
$template->assign( array(
'ALT_IMG' => $element_info['file'],
'COOKIE_PATH' => cookie_path(),
)
);
$template->set_filename('asize_picture_js', realpath(ASIZE_PATH.'picture_js.tpl'));
$template->parse('asize_picture_js');
return $template->parse( 'default_content', true);
}
function asize_picture_prefilter($content, &$smarty)
{
$pattern = '#\{foreach from=\$current\.unique_derivatives#';
$replacement = '
✔ {\'Automatic\'|@translate}
{foreach from=$current.unique_derivatives';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
?>