Skip to content

Commit

Permalink
streamline resize image process
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Aug 18, 2012
1 parent 216dada commit 0d2c789
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 42 deletions.
3 changes: 0 additions & 3 deletions ext/resize/main.php
Expand Up @@ -144,9 +144,6 @@ public function onPageRequest(PageRequestEvent $event) {
} catch (ImageResizeException $e) {
$this->theme->display_resize_error($page, "Error Resizing", $e->error);
}
} else {
/* Display options for resizing */
$this->theme->display_resize_page($page, $image_id);
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions ext/resize/style.css

This file was deleted.

42 changes: 8 additions & 34 deletions ext/resize/theme.php
Expand Up @@ -8,11 +8,15 @@ public function get_resize_html(/*int*/ $image_id) {
global $user, $config;

$i_image_id = int_escape($image_id);
$default_width = $config->get_int('resize_default_width');
$default_height = $config->get_int('resize_default_height');

$html = "
".make_form(make_link("resize"),'POST',false,'resize_image')."
<input type='hidden' name='image_id' value='$i_image_id' />
<input type='submit' value='Resize' id='resize_image_submit' />
$html .= "
".make_form(make_link('resize/'.$i_image_id), 'POST')."
<input type='hidden' name='image_id' value='$i_image_id'>
<input id='resize_width' style='width: auto;' size='5' name='resize_width' type='text' value='".$default_width."'> x
<input id='resize_height' style='width: auto;' size='5' name='resize_height' type='text' value='".$default_height."'>
<input id='resizebutton' type='submit' value='Resize'>
</form>
";

Expand All @@ -25,35 +29,5 @@ public function display_resize_error(Page $page, /*string*/ $title, /*string*/ $
$page->add_block(new NavBlock());
$page->add_block(new Block($title, $message));
}

public function display_resize_page(Page $page, /*int*/ $image_id) {
global $config;

$default_width = $config->get_int('resize_default_width');
$default_height = $config->get_int('resize_default_height');

$image = Image::by_id($image_id);
$thumbnail = $this->build_thumb_html($image, null);

$html = "<div style='clear:both;'></div>
<p>Resize Image ID ".$image_id."<br>".$thumbnail."</p>
<p>Please note: You will have to refresh the image page, or empty your browser cache.</p>
<p>Enter the new size for the image, or leave blank to scale the image automatically.</p><br>"
.make_form(make_link('resize/'.$image_id), 'POST', $multipart=True,'form_resize')."
<input type='hidden' name='image_id' value='$image_id'>
<table id='large_upload_form'>
<tr><td>New Width</td><td colspan='3'><input id='resize_width' name='resize_width' type='text' value='".$default_width."'></td></tr>
<tr><td>New Height</td><td colspan='3'><input id='resize_height' name='resize_height' type='text' value='".$default_height."'></td></tr>
<tr><td colspan='4'><input id='resizebutton' type='submit' value='Resize'></td></tr>
</table>
</form>
";

$page->set_title("Resize Image");
$page->set_heading("Resize Image");
$page->add_block(new NavBlock());
$page->add_block(new Block("Resize Image", $html, "main", 20));

}
}
?>

0 comments on commit 0d2c789

Please sign in to comment.