Heya All,
At the moment I am building a universal product locator page parser. Or what-shall-we-call-it.
Part of it is a way to locate images for the product featuring on the page a person is suggesting.
I am thinking about oing the following: Parsing the page, and locating all image tags. However, the images found in this way might a.f.a.i.k. be based on the website root, the relative path or the full url.
Is there any way to be certain which path to use for an image?
The simple way I am not finding the images from the tags is:
function get_images($text)
{
$regex = '/<img\s[^>]*src="([^"]+)"[^>]*>/si';
if(preg_match_all($regex, $text, $matches))
{
return $matches;
}
else
{
return -1;
}
}
Does anybody have abetter way? Is there a goodw ay of finding the full pathname of the image?
I want to suggest an image, and am thinking about using the image dimensions to decide which is most likely to be a product image. E.g., an image approximating 300*150pixels is a good candidate. Does anybody have experience with this?
What woul dbe a good way to retrieve the image dimensions, noting that the dimensions in the tags are dificult to retrieve (?)
Cheers,
J.