matula / firstimg
Get the first image from a web page
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/matula/firstimg
Requires
- php: >=5.4.0
- intervention/image: 2.0.6
- symfony/dom-crawler: 2.5.2
Requires (Dev)
- phpunit/phpunit: 4.1.*
This package is not auto-updated.
Last update: 2025-10-07 06:34:32 UTC
README
Simple library that returns the first image on a web page. Though, only if it's in an <img>
tag.
Installation
Add to your composer.json file
"matula/firstimg": "dev-master"
Usage
$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.
TODO
- better documentation
- customize the image's filename/extension
- customize image resizing, or disable
- better formatting, etc