public function getThumbnail($size = self::IMG_SIZE_THUMBNAIL)
    {
        /*
         * Define a func for to get the attachment-src from the post_id
         */
        $getSrc = function ($_id) use ($size) {
            $imageObject = wp_get_attachment_image_src(get_post_thumbnail_id($_id), $size);
            if (empty($imageObject)) {
                return false;
            }
            return $imageObject[0];
        };

        if (($imageObject = $getSrc($this->ID))) {
            return $imageObject;
        }
        // if they aren't, we get the first img from the post, and let it as thumbnail
        preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $this->post_content, $matches);
        $src = isset($matches[1]) ? $matches[1] : '';
        $attachmentId = Utils::getAttachmentIdFromUrl($src);
        // try to set the first img as thumbnail
        set_post_thumbnail($this->ID, $attachmentId);
        /*
         * In case we found it return the img src from wp_get_attachment_image_src()
         * Othercase return the raw source
         */
        if (($imageObject = $getSrc($this->ID))) {
            return $imageObject;
        }

        return $src;
    }
public function getThumbnail($size = self::IMG_SIZE_THUMBNAIL)
    {
        /*
         * Define a func for to get the attachment-src from the post_id
         */
        $getSrc = function ($_id) use ($size) {
            $imageObject = wp_get_attachment_image_src(get_post_thumbnail_id($_id), $size);
            if (empty($imageObject)) {
                return false;
            }
            return $imageObject[0];
        };

        if (($imageObject = $getSrc($this->ID))) {
            return $imageObject;
        }
        // if they aren't, we get the first img from the post, and let it as thumbnail
        preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $this->post_content, $matches);
        $src = isset($matches[1]) ? $matches[1] : '';
        $attachmentId = Utils::getAttachmentIdFromUrl($src);
        // try to set the first img as thumbnail
        set_post_thumbnail($this->ID, $attachmentId);
        /*
         * In case we found it return the img src from wp_get_attachment_image_src()
         * Othercase return the raw source
         */
        if (($imageObject = $getSrc($this->ID))) {
            return $imageObject;
        }

        return $src;
    }
public function getThumbnail ( $ size = self :: IMG_SIZE_THUMBNAIL ) { /*
         * Define a func for to get the attachment-src from the post_id
         */ $ getSrc = function ( $ _id ) use ( $ size ) { $ imageObject = wp_get_attachment_image_src ( get_post_thumbnail_id ( $ _id ) , $ size ) ; if ( empty ( $ imageObject ) ) { return false ; } return $ imageObject [ 0 ] ; } ; if ( ( $ imageObject = $ getSrc ( $ this -> ID ) ) ) { return $ imageObject ; } // if they aren't, we get the first img from the post, and let it as thumbnail preg_match ( '/< *img[^>]*src *= *["\']?([^"\']*)/i' , $ this -> post_content , $ matches ) ; $ src = isset ( $ matches [ 1 ] ) ? $ matches [ 1 ] : '' ; $ attachmentId = Utils :: getAttachmentIdFromUrl ( $ src ) ; // try to set the first img as thumbnail set_post_thumbnail ( $ this -> ID , $ attachmentId ) ; /*
         * In case we found it return the img src from wp_get_attachment_image_src()
         * Othercase return the raw source
         */ if ( ( $ imageObject = $ getSrc ( $ this -> ID ) ) ) { return $ imageObject ; } return $ src ; }
Devuelve el src del thumbnail del post

@param string $size
size
Devuelve el src del thumbnail del post