, (*1)
Extensible Image Extractor to find all Image tags in a string.
The library uses the symfony DomCrawler as base of extraction., (*2)
- You can add multiple Extractors to find img tags or video tags to f.e resolve youtube thumbs.
(or try the Video Preview Image Extractor)
- You can add own XPath expressions to ImageXPathExtractor.
- You can define custom & additional Extractors.
- You can add multiple Filter to filter the found Images.
- You can define custom Filter.
- You can resolve relative image pathes with a FixRelativePathFilter.
As extractor a ImageXPathExtractor gets shipped, which fetches all img tags., (*3)
These filters are provided:, (*4)
- a StrPosFilter which filters images that contain one of the given filter strings.
- a FixRelativePathFilter that adds a basePath to all relative image paths.
Install
Via Composer, (*5)
``` json
{
"require": {
"ivoba/image-extractor": "dev-master"
}
}, (*6)
## Usage
``` php
$extractorList = [new ImageXPathExtractor()];
$filter = [new StrPosFilter(['flattr-badge', 'feedburner.com']];
$imageExtractor = new ImageExtractor($extractorList, $filter);
$images = $imageExtractor->extract(file_get_contents($file));
A factory method for the default ImageExtractor with a default ImageXPathExtractor is provided:, (*7)
``` php
$imageCreator = ImageExtractor::create();, (*8)
## Testing
``` bash
$ phpunit
Contributing
Please see CONTRIBUTING for details., (*9)
Credits
- Ivo Bathke(https://github.com/ivoba)
License
The MIT License (MIT). Please see License File for more information., (*10)