1 | <?php |
||
8 | class Image |
||
9 | { |
||
10 | public $image; |
||
11 | |||
12 | protected $postmeta; |
||
13 | protected $utility; |
||
14 | |||
15 | public function __construct( PostMeta $postmeta, Utility $utility ) |
||
20 | |||
21 | /** |
||
22 | * @param int|string $attachment |
||
23 | * |
||
24 | * @return self |
||
25 | */ |
||
26 | public function get( $attachment ) |
||
46 | |||
47 | public function render( $size = 'large' ) |
||
53 | |||
54 | protected function normalize( $attachmentId ) |
||
55 | { |
||
56 | if( !filter_var( $attachmentId, FILTER_VALIDATE_INT )) { |
||
57 | $attachmentId = $this->postmeta->get( $attachmentId ); |
||
58 | } |
||
59 | |||
60 | $attachment = get_post( $attachmentId ); |
||
61 | |||
62 | if( is_null( $attachment ) || $attachment->post_type != 'attachment' )return; |
||
63 | |||
64 | return $attachment->ID; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param mixed $fallback |
||
69 | * |
||
70 | * @return array |
||
71 | */ |
||
72 | protected function normalizeSrc( array $image, $fallback = false ) |
||
83 | } |
||
84 |