src/lib/Post.php
/**
     * @param array $attr Image atrtributes.
     * @param bool $link Link image to post URL?
     */
@param array $attr Image atrtributes.
@param array $attr Image atrtributes .
public function thumbnail(
        $size = '',
        array $attr = [],
        bool $link = true
    ): string {
        $out = '';
        $class = '';
        if (\is_string($size)) {
            if (0 === \stripos($size, 'avatar__')) {
                $size = \absint(\str_ireplace('avatar__', '', $size));
                return \get_avatar($this->get()->post_author, $size);
            }
            $size_split = \explode(',', $size);
            if (0 !== \absint($size_split[0])) {
                $size = $size_split;
            } else {
                $class .= \sanitize_title($size);
            }
        }
        $attr['class'] = $attr['class'] ?? '';
        $attr['class'] .= " thumb {$class}";
        $attr['class'] = \trim($attr['class']);
        if ($link) {
            $out .= '<a class="image-link post-thumb-link" href="'.
                \get_permalink($this->get()).'" rel="bookmark">';
        }
        $out .= \get_the_post_thumbnail($this->get(), $size, $attr);
        if ($link) {
            $out .= '</a>';
        }
        return $out;
    }
public function thumbnail ( $ size = '' , array $ attr = [ ] , bool $ link = true ) : string { $ out = '' ; $ class = '' ; if ( \ is_string ( $ size ) ) { if ( 0 === \ stripos ( $ size , 'avatar__' ) ) { $ size = \ absint ( \ str_ireplace ( 'avatar__' , '' , $ size ) ) ; return \ get_avatar ( $ this -> get ( ) -> post_author , $ size ) ; } $ size_split = \ explode ( ',' , $ size ) ; if ( 0 !== \ absint ( $ size_split [ 0 ] ) ) { $ size = $ size_split ; } else { $ class .= \ sanitize_title ( $ size ) ; } } $ attr [ 'class' ] = $ attr [ 'class' ] ?? '' ; $ attr [ 'class' ] .= "  thumb  { $ class } " ; $ attr [ 'class' ] = \ trim ( $ attr [ 'class' ] ) ; if ( $ link ) { $ out .= '<a class="image-link post-thumb-link" href="' . \ get_permalink ( $ this -> get ( ) ) . '" rel="bookmark">' ; } $ out .= \ get_the_post_thumbnail ( $ this -> get ( ) , $ size , $ attr ) ; if ( $ link ) { $ out .= '</a>' ; } return $ out ; }
@param array $attr Image atrtributes.
@param array $attr Image atrtributes .
// If $size contain 2 comma-separated integers