Skip to content

Commit

Permalink
Setup on attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
xavivars committed Jul 19, 2022
1 parent 1500e48 commit 034f247
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ class Attachment extends Post
*/
public $caption;

/**
* Create and initialize a new instance of the called Post class
* (i.e. Timber\Attachment or a subclass).
*
* @internal
* @return Timber\Attachment
*/
public static function build(WP_Post $wp_post): self
{
$post = parent::build($wp_post);

$post->caption = $post->post_excerpt;

return $post;
}

/**
* Gets the src for an attachment.
*
Expand Down

0 comments on commit 034f247

Please sign in to comment.