WebsiteParser::getImageSources( boolean $grab = false )

Extract all images sources from grabbed contents

Description

Parameters

$grab

(boolean) (Optional) , flag to perform real time grab or use class content

Default value: false

Return

(array,) an array of extracted images sources

Source

File: bp-activity/vendors/website-parser/website_parser.php

    public function getImageSources($grab = false)
    {
        if ($grab)
            $this->grabContent();

        if (!is_null($this->content)) {

            preg_match_all($this->img_expression, $this->content, $match_images);

            if (isset($match_images[2]) && count($match_images[2])) {
                foreach ($match_images[2] as $match_image) {
                    $match_image = trim($match_image);

                    if ($match_image) {

                        if (!preg_match($this->full_link_pattern, $match_image, $match))
                            $match_image = $this->sanitizeUrl($match_image);

                        $this->image_sources[] = $match_image;
                    }
                }
            }
        }

        $this->image_sources = array_values(array_unique(array_filter($this->image_sources)));

        return $this->image_sources;

    }

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.