2020-01-26 13:19:35 +00:00
|
|
|
<?php declare(strict_types=1);
|
2011-09-04 03:13:41 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class ResizeImageTheme extends Themelet
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Display a link to resize an image
|
|
|
|
*/
|
|
|
|
public function get_resize_html(Image $image)
|
|
|
|
{
|
|
|
|
global $config;
|
2011-09-04 03:13:41 +00:00
|
|
|
|
2019-06-18 18:45:59 +00:00
|
|
|
$default_width = $config->get_int(ResizeConfig::DEFAULT_WIDTH);
|
|
|
|
$default_height = $config->get_int(ResizeConfig::DEFAULT_HEIGHT);
|
2013-05-18 08:26:20 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (!$default_width) {
|
|
|
|
$default_width = $image->width;
|
|
|
|
}
|
|
|
|
if (!$default_height) {
|
|
|
|
$default_height = $image->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
$html = "
|
2013-05-18 08:26:20 +00:00
|
|
|
".make_form(make_link("resize/{$image->id}"), 'POST')."
|
|
|
|
<input type='hidden' name='image_id' value='{$image->id}'>
|
2013-05-18 09:14:27 +00:00
|
|
|
<input id='original_width' name='original_width' type='hidden' value='{$image->width}'>
|
|
|
|
<input id='original_height' name='original_height' type='hidden' value='{$image->height}'>
|
|
|
|
<input id='resize_width' style='width: 70px;' name='resize_width' type='number' min='1' value='".$default_width."'> x
|
|
|
|
<input id='resize_height' style='width: 70px;' name='resize_height' type='number' min='1' value='".$default_height."'>
|
|
|
|
<br><label><input type='checkbox' id='resize_aspect' name='resize_aspect' style='max-width: 20px;' checked='checked'> Keep Aspect</label>
|
|
|
|
<br><input id='resizebutton' type='submit' value='Resize'>
|
2011-09-04 03:13:41 +00:00
|
|
|
</form>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function display_resize_error(Page $page, string $title, string $message)
|
|
|
|
{
|
|
|
|
$page->set_title("Resize Image");
|
|
|
|
$page->set_heading("Resize Image");
|
|
|
|
$page->add_block(new NavBlock());
|
|
|
|
$page->add_block(new Block($title, $message));
|
|
|
|
}
|
2011-09-04 03:13:41 +00:00
|
|
|
}
|