diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index 3d5042f..dbcf183 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -95,9 +95,11 @@ 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"]); - $current_max = array(intval($width), intval($height)); + 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; } @@ -207,4 +209,4 @@ class ComicPress { } } -?> \ No newline at end of file +?> diff --git a/test/ComicPressTest.php b/test/ComicPressTest.php index 808b6f0..34d6915 100644 --- a/test/ComicPressTest.php +++ b/test/ComicPressTest.php @@ -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)); + } } -?> \ No newline at end of file +?>