Documentation

HtmlHeadThumbnailParser extends FastHtmlTag
in package

The head parser extracts links and meta from HTML responses.

Tags
codeCoverageIgnore

Table of Contents

Constants

LINK_REL_IMAGE  = ['image_src']
META_PROPERTIES_IMAGE  = ['og:image', 'og:image:url', 'og:image:secure_url', 'twitter:image', 'twitter:image:src', 'lp:image']
META_PROPERTIES_TITLE  = ['og:title', 'twitter:title', 'lp:title', 'dcterms.title', 'article:title', 'headline', 'article.headline', 'parsely-title']
XML_XPATH_IMAGE  = ['//itunes:image/@href']
XML_XPATH_TITLE  = ['//channel/title']

Properties

$headParserResult  : array<string|int, mixed>
Result of the last `$headParser` execution.

Methods

__construct()  : mixed
C'tor.
extractFromUrls()  : mixed
Send multiple HTTP requests simultaneously and return a map of URL to image preview URL and additional data.
convertUrlToThumbnailFromResponse()  : array<string|int, mixed>|false
Pass in some response infos about a requested URL and we will try to detect a thumbnail URL and other infos like title and description for you.
convertUrlToThumbnailFromXml()  : mixed
Use the power of `SimpleXMLElement` and XPath to extract title and images from a given XML body.
extractXpathResToSingleValue()  : mixed
Check if a given `->xpath()` result is present and extract a single value.

Constants

META_PROPERTIES_IMAGE

public mixed META_PROPERTIES_IMAGE = ['og:image', 'og:image:url', 'og:image:secure_url', 'twitter:image', 'twitter:image:src', 'lp:image']

META_PROPERTIES_TITLE

public mixed META_PROPERTIES_TITLE = ['og:title', 'twitter:title', 'lp:title', 'dcterms.title', 'article:title', 'headline', 'article.headline', 'parsely-title']

Properties

$headParserResult

Result of the last `$headParser` execution.

private array<string|int, mixed> $headParserResult = []

Methods

extractFromUrls()

Send multiple HTTP requests simultaneously and return a map of URL to image preview URL and additional data.

public extractFromUrls(array<string|int, string> $urls) : mixed

If there could not be found an image, the requested URL does not exist in the result array.

Parameters
$urls : array<string|int, string>

convertUrlToThumbnailFromResponse()

Pass in some response infos about a requested URL and we will try to detect a thumbnail URL and other infos like title and description for you.

protected convertUrlToThumbnailFromResponse(string $requestedUrl, string $contentType, string $body) : array<string|int, mixed>|false
Parameters
$requestedUrl : string
$contentType : string
$body : string
Return values
array<string|int, mixed>|false

convertUrlToThumbnailFromXml()

Use the power of `SimpleXMLElement` and XPath to extract title and images from a given XML body.

protected convertUrlToThumbnailFromXml(string $body) : mixed
Parameters
$body : string

extractXpathResToSingleValue()

Check if a given `->xpath()` result is present and extract a single value.

protected extractXpathResToSingleValue(array<string|int, static>|false|null $result) : mixed
Parameters
$result : array<string|int, static>|false|null

        
On this page

Search results