editor max image size

This commit is contained in:
John Bintz 2009-11-12 12:25:48 -05:00
parent d27c3040bf
commit 9b3b25f7fa
2 changed files with 29 additions and 5 deletions

View File

@ -95,10 +95,12 @@ class ComicPress {
}
function editor_max_image_size($current_max, $size) {
if (isset($this->comicpress_options["${size}_dimensions"])) {
list($width, $height) = explode('x', $this->comicpress_options["${size}_dimensions"]);
if (isset($this->comicpress_options['image_types'][$size])) {
if (isset($this->comicpress_options['image_types'][$size]['dimensions'])) {
list($width, $height) = explode('x', $this->comicpress_options['image_types'][$size]['dimensions']);
$current_max = array(intval($width), intval($height));
}
}
return $current_max;
}

View File

@ -210,6 +210,28 @@ class ComicPressTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(array('test3', 'comic', 'test', 'test2'), $this->cp->intermediate_image_sizes(array('test3')));
}
function providerTestEditorMaxImageSize() {
return array(
array(array(1, 1), 'comic', array(760, 500)),
array(array(1, 1), 'test', array(1, 1)),
);
}
/**
* @dataProvider providerTestEditorMaxImageSize
*/
function testEditorMaxImageSize($input, $type, $expected_result) {
$this->cp->comicpress_options = array(
'image_types' => array(
'comic' => array(
'dimensions' => '760x500'
)
)
);
$this->assertEquals($expected_result, $this->cp->editor_max_image_size($input, $type));
}
}
?>