I am parsing a page using PHPQuery.
At some point I have obtained all images on the page using:
$url = "http://mywebsite.com";
$all = phpQuery::newDocumentFileHTML($url, $charset = 'utf-8');
// list of all images
$imgsrc = $all->find('img');
now I am interacting this list
foreach ($imgsrc as $img) {
$width = need magic command to extract image width
$height = need magic command to extract image height
}
The problem is this. The img attribute does not have a width
or a height
attribute but its class has.
The image tag is like this:
<img src="img1.png" class="alfa">
I need to get the width and height defined by that class.
I can get the class name by doing
$className = pq($img)->attr('class');
How do I do obtain the width/height of that class now?
list($width, $height, $type, $attr) = getimagesize("img/flag.jpg");
to get the image height and width.