TestTimberImage::get_image_attachment PHP Method

get_image_attachment() public static method

public static get_image_attachment ( $pid, $file = 'arch.jpg' )
    public static function get_image_attachment($pid = 0, $file = 'arch.jpg')
    {
        $filename = self::copyTestImage($file);
        $filetype = wp_check_filetype(basename($filename), null);
        $attachment = array('post_title' => 'The Arch', 'post_content' => '', 'post_mime_type' => $filetype['type']);
        $iid = wp_insert_attachment($attachment, $filename, $pid);
        return $iid;
    }

Usage Example

Ejemplo n.º 1
0
 function testTimberImageInTwigToString()
 {
     $iid = TestTimberImage::get_image_attachment();
     $str = '{{TimberImage(' . $iid . ')}}';
     $compiled = Timber::compile_string($str);
     $this->assertEquals('http://example.org/wp-content/uploads/' . date('Y') . '/' . date('m') . '/arch.jpg', $compiled);
 }
All Usage Examples Of TestTimberImage::get_image_attachment