Simple library that returns the first image on a web page. Though, only if it's in an <img>
tag.
Add to your composer.json file
"matula/firstimg": "dev-master"
$url = 'http://google.com';
$image = new Matula\Firstimg\Firstimg($url);
echo $image->downloadImage();
This will find the first image on the page and download it. Currently, it also resizes the image to 100px.
- better documentation
- customize the image's filename/extension
- customize image resizing, or disable
- better formatting, etc