Get the `base64` encoded image content

@param bool $to_href Set to `true` to get a full result to use in `img` tag
@return string
12513
public function getBase64Content($to_href = false)
    {
        if ($this->exists() && $this->isImage()) {
            $image_infos = $this->getImageInfos();
            $base64 = '';
            if ($to_href) {
                $type = pathinfo($this->getRealPath(), PATHINFO_EXTENSION);
                $base64 .= 'data:image/' . $type . ';base64,';
            }
            $data = file_get_contents($this->getRealPath());
            $base64 .= base64_encode($data);
            return $base64;
        }
        return '';
    }
1288082
public function getBase64()
    {
        if ($this->owner->exists()) {
            $file = $this->owner->getFullPath();
            $mime = mime_content_type($file);
            $fileContent = file_get_contents($file);
            return "data://$mime;base64," . base64_encode($fileContent);
        }
        
        return null;
    }
835865
private function getFavImage($each_fav)
    {
        $image = $each_fav->find('a', 0)->style;
        preg_match('/\'([^\'])*/', $image, $image);
        $image = substr($image[0], 1);

        return Helper::imageUrlCleaner($image);
    }
549518
public function getThumbnailAsBase64String($uri, $defaultAllowed = false)
    {
        $url = self::makeUrl($uri, $defaultAllowed);
        $response = $this->service->makeRequest($url, array(200, 204), 'GET', null, true, 'application/json', 'text/plain');

        return $response['body'];
    }
1193922
public function getFileContentsInlineMap($includeLastExtension = true)
    {
        $ret = $this->_fileContents;
        if ($this->_mimeType == 'text/css') {
            $ret .= "\n/*# sourceMappingURL=data:application/json;base64,".base64_encode($this->getMapContents($includeLastExtension))." */\n";
        } else {
            $ret .= "\n//# sourceMappingURL=data:application/json;base64,".base64_encode($this->getMapContents($includeLastExtension))."\n";
        }
        return $ret;
    }
1023101
public function getSummaryHash(bool $rawBinary = false): string
    {
        /* Make a XOR-encrypted copy of the hash state to prevent PHP's
         * interned strings from overwriting the hash state and causing
         * corruption. */
        $len = Util::strlen($this->summaryHashState);
        $pattern = \random_bytes($len);
        $tmp = $pattern ^ $this->summaryHashState;

        $finalHash = SodiumCompat::crypto_generichash_final($this->summaryHashState);

        /* Restore hash state */
        $this->summaryHashState = $tmp ^ $pattern;
        if ($rawBinary) {
            return $finalHash;
        }
        return Base64UrlSafe::encode($finalHash);
    }
1331918
public function getThumbnailEncoded()
    {
        if ($data = base64_decode($this->getThumbnail(), $strict = true)) {
            // In case we don't have the file info extension enabled,
            // we'll set the jpeg mime type as default.
            $mime = 'image/jpeg';

            $image = base64_encode($data);

            if (function_exists('finfo_open')) {
                $finfo = finfo_open();

                $mime = finfo_buffer($finfo, $data, FILEINFO_MIME_TYPE);

                return "data:$mime;base64,$image";
            }

            return "data:$mime;base64,$image";
        }
    }
725766
public function PinterestShareLink()
    {
        $pinImage = ($this->owner->hasMethod('getPinterestImage')) ? $this->owner->getPinterestImage() : $this->owner->getOGImage();
        if ($pinImage) {
            // OGImage may be an Image object or an absolute URL
            $imageURL = rawurlencode((is_string($pinImage)) ? $pinImage : $pinImage->getAbsoluteURL());
            $pageURL = rawurlencode($this->owner->AbsoluteLink());
            $description = rawurlencode($this->owner->getOGTitle());
            // Combine Title, link and image in to rich link
            return "http://www.pinterest.com/pin/create/button/?url=$pageURL&media=$imageURL&description=$description";
        }

        return false;
    }
798308
public function toHtml(bool $preview = false)
    {
        $html = '';
        if ($preview) {
            if ($this->getImageUrl()) {
                $html = "<img src='{$this->getImageUrl()}' style='max-width: 100%;' />";
            }
        }
        if ($this->getVideoUrl()) {
            $html = "<iframe src='{$this->getVideoUrl()}' frameborder='0' allowfullscreen></iframe>";
        }

        return $html;
    }
431023
public function to_base64()
    {
        if (!empty($this->get_upload_path())) {
            return \base64_encode(\file_get_contents($this->get_upload_path()));
        }

        return \base64_encode(\file_get_contents($this->get_tmp_path()));
    }
56608
protected function getURLData()
    {
        $data = base64_encode(file_get_contents($this->src));
        $im = getimagesize($this->src);
        $data = "data:" . $im['mime'] . ";base64," . $data;

        return $data;
    }
665006
public function getImageAsString()
    {
        $data = null;
        ob_start();
        $this->show(true);
        $data = ob_get_contents();
        ob_end_clean();

        return $data;
    }
628441
public function toBase64() {
        ob_start ();
        $this->saveAs();
        $data = ob_get_contents();
        ob_end_clean();
        return 'data:image/'.$this->realType.';base64,'.base64_encode($data);
    }
432845
public function getQuery($toArray = false)
    {
        $result = $toArray ? $this->_query : http_build_query($this->_query, '', '&');
        return $result;
    }
369222
public static function href($link) {
        if(isset($link['uri']) || isset($link['fragment'])) {
            return ' href="'.URI::getHref($link).'"';
        }
        return false;
    }
422851
public function getMainImage()
    {
        $imgUrl = false;

        if ($this->getImage() !== null) {
            $imgUrl = $this->getImage();
        }

        if (!$imgUrl) {
            foreach ($this->dom->getElementsByTagName('link') as $link) {
                /** @var \DOMElement $link */
                /*
                 * Check for the rel attribute, then check if the rel attribute is either img_src or image_src, and
                 * finally check for the existence of the href attribute, which should hold the image url.
                 */
                if ($link->hasAttribute('rel') && ($link->getAttribute('rel') === 'img_src' || $link->getAttribute('rel') === 'image_src') && $link->hasAttribute('href')) {
                    $imgUrl = $link->getAttribute('href');
                    break;
                }
            }
        }

        if (!empty($imgUrl) && $this->configuration->getFixRelativeURLs()) {
            $this->setImage($this->toAbsoluteURI($imgUrl));
        }
    }
1299727
public function toString()
    {
        $items = $this->data;

        $attachedBaseLib = false;
        $return = array('file' => '', 'script' => '');
        foreach ($items as $item) {
            if ($item['mode'] == 'file' && isset($item['attributes']['src'])) {
                // looking for duplicated base library
                if ($item['attributes']['src'] == $this->getBaseLibrary() && !$attachedBaseLib) {
                    $attachedBaseLib = true;
                } elseif ($item['attributes']['src'] == $this->getBaseLibrary()) {
                    // we have attached base library before
                    continue;
                }
            }

            $return[$item['mode']] .= PHP_EOL.
                $this->startElement().$this->writeAttributes($item['attributes']).$this->endElement().
                (($item['mode'] == 'script') ? $this->overrideScript($item['content']) : '').
                $this->startElement(true).$this->endElement()
            ;
        }

        $return = $return['file'].PHP_EOL.
            $return['script'].PHP_EOL;

        return $return;
    }