checkSize() 공개 정적인 메소드

public static checkSize ( $file, $width, $height )
예제 #1
0
 function testCropHeight()
 {
     $arch = TestTimberImage::copyTestImage('arch.jpg');
     $resized = TimberImageHelper::resize($arch, false, 250);
     $resized = str_replace('http://example.org', '', $resized);
     $resized = TimberUrlHelper::url_to_file_system($resized);
     $is_sized = TestTimberImage::checkSize($resized, 375, 250);
     $this->assertTrue($is_sized);
 }
 function testLetterboxSixCharHex()
 {
     $data = array();
     $file_loc = TestTimberImage::copyTestImage('eastern.jpg');
     $upload_dir = wp_upload_dir();
     $new_file = TimberImageHelper::letterbox($upload_dir['url'] . '/eastern.jpg', 500, 500, '#FFFFFF', true);
     $location_of_image = TimberImageHelper::get_server_location($new_file);
     $this->assertTrue(TestTimberImage::checkSize($location_of_image, 500, 500));
     //whats the bg/color of the image
     $image = imagecreatefromjpeg($location_of_image);
     $pixel_rgb = imagecolorat($image, 1, 1);
     $colors = imagecolorsforindex($image, $pixel_rgb);
     $this->assertEquals(255, $colors['red']);
     $this->assertEquals(255, $colors['blue']);
     $this->assertEquals(255, $colors['green']);
 }
예제 #3
0
 function testWPMLurlLocal()
 {
     // this test replicates the url issue caused by the WPML language identifier in the url
     // However, WPML can't be installed with composer so this test mocks the WPML plugin
     // WPML uses a filter to alter the home_url
     $home_url_filter = function ($url) {
         return $url . '/en';
     };
     add_filter('home_url', $home_url_filter, -10, 4);
     // test with a local and external file
     $img = 'arch.jpg';
     $img = TestTimberImage::copyTestImage($img);
     $resized = TimberImageHelper::resize($img, 50, 50);
     // make sure the base url has not been duplicated (https://github.com/timber/timber/issues/405)
     $this->assertLessThanOrEqual(1, substr_count($resized, 'example.org'));
     // make sure the image has been resized
     $resized = TimberUrlHelper::url_to_file_system($resized);
     $this->assertTrue(TestTimberImage::checkSize($resized, 50, 50), 'image should be resized');
 }