Ejemplo n.º 1
0
 function testImageSizes()
 {
     $pid = $this->factory->post->create();
     $filename = self::copyTestImage('arch.jpg');
     $attachment = array('post_title' => 'The Arch', 'post_content' => '');
     $iid = wp_insert_attachment($attachment, $filename, $pid);
     $image = new TimberImage($iid);
     $this->assertEquals(1500, $image->width());
     $this->assertEquals(1000, $image->height());
     $this->assertEquals($pid, $image->parent()->id);
     $this->assertEquals(1.5, $image->aspect());
 }
 function testImageResizeRetinaFilter()
 {
     $filename = TestTimberImage::copyTestImage('eastern.jpg');
     $wp_filetype = wp_check_filetype(basename($filename), null);
     $post_id = $this->factory->post->create();
     $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($filename)), 'post_excerpt' => '', 'post_status' => 'inherit');
     $attach_id = wp_insert_attachment($attachment, $filename, $post_id);
     add_post_meta($post_id, '_thumbnail_id', $attach_id, true);
     $data = array();
     $data['post'] = new TimberPost($post_id);
     $str = '{{post.thumbnail.src|resize(100, 50)|retina(3)}}';
     $compiled = Timber::compile_string($str, $data);
     $img = new TimberImage($compiled);
     $this->assertContains('@3x', $compiled);
     $this->assertEquals(300, $img->width());
 }
Ejemplo n.º 3
0
 function testInitFromFilePath()
 {
     $image_file = self::copyTestImage();
     $image = new TimberImage($image_file);
     $this->assertEquals(1500, $image->width());
 }