Image to Post - res limit
This commit is contained in:
parent
61250bd3a3
commit
21f48456a2
@ -19,16 +19,16 @@ class ResolutionLimit extends Extension
|
|||||||
$image = $event->image;
|
$image = $event->image;
|
||||||
|
|
||||||
if ($min_w > 0 && $image->width < $min_w) {
|
if ($min_w > 0 && $image->width < $min_w) {
|
||||||
throw new UploadException("Image too small");
|
throw new UploadException("Post too small");
|
||||||
}
|
}
|
||||||
if ($min_h > 0 && $image->height < $min_h) {
|
if ($min_h > 0 && $image->height < $min_h) {
|
||||||
throw new UploadException("Image too small");
|
throw new UploadException("Post too small");
|
||||||
}
|
}
|
||||||
if ($max_w > 0 && $image->width > $max_w) {
|
if ($max_w > 0 && $image->width > $max_w) {
|
||||||
throw new UploadException("Image too large");
|
throw new UploadException("Post too large");
|
||||||
}
|
}
|
||||||
if ($max_h > 0 && $image->height > $max_h) {
|
if ($max_h > 0 && $image->height > $max_h) {
|
||||||
throw new UploadException("Image too large");
|
throw new UploadException("Post too large");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($ratios) > 0) {
|
if (count($ratios) > 0) {
|
||||||
@ -49,7 +49,7 @@ class ResolutionLimit extends Extension
|
|||||||
}
|
}
|
||||||
if ($valids > 0 && !$ok) {
|
if ($valids > 0 && !$ok) {
|
||||||
throw new UploadException(
|
throw new UploadException(
|
||||||
"Image needs to be in one of these ratios: ".
|
"Post needs to be in one of these ratios: ".
|
||||||
html_escape($config->get_string("upload_ratios", ""))
|
html_escape($config->get_string("upload_ratios", ""))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ class ResolutionLimitTest extends ShimmiePHPUnitTestCase
|
|||||||
$this->log_in_as_user();
|
$this->log_in_as_user();
|
||||||
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
//$this->assert_response(302);
|
//$this->assert_response(302);
|
||||||
$this->assert_no_text("Image too large");
|
$this->assert_no_text("Post too large");
|
||||||
$this->assert_no_text("Image too small");
|
$this->assert_no_text("Post too small");
|
||||||
$this->assert_no_text("ratio");
|
$this->assert_no_text("ratio");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class ResolutionLimitTest extends ShimmiePHPUnitTestCase
|
|||||||
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
$this->assertTrue(false, "Invalid-size image was allowed");
|
$this->assertTrue(false, "Invalid-size image was allowed");
|
||||||
} catch (UploadException $e) {
|
} catch (UploadException $e) {
|
||||||
$this->assertEquals("Image too small", $e->getMessage());
|
$this->assertEquals("Post too small", $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class ResolutionLimitTest extends ShimmiePHPUnitTestCase
|
|||||||
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
$this->assertTrue(false, "Invalid-size image was allowed");
|
$this->assertTrue(false, "Invalid-size image was allowed");
|
||||||
} catch (UploadException $e) {
|
} catch (UploadException $e) {
|
||||||
$this->assertEquals("Image too large", $e->getMessage());
|
$this->assertEquals("Post too large", $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class ResolutionLimitTest extends ShimmiePHPUnitTestCase
|
|||||||
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
$this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
$this->assertTrue(false, "Invalid-size image was allowed");
|
$this->assertTrue(false, "Invalid-size image was allowed");
|
||||||
} catch (UploadException $e) {
|
} catch (UploadException $e) {
|
||||||
$this->assertEquals("Image needs to be in one of these ratios: 16:9", $e->getMessage());
|
$this->assertEquals("Post needs to be in one of these ratios: 16:9", $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user