I have an image with source that looks like
<img alt="" src="./userfiles/images/Water%20lilies(1).jpg" style="width:800px;height:600px;" />
I'd like to find out if the width is greater than 750px if yes the need to change the style="width开发者_如何学Go: xxx"
to be style="width: 750px;"
Is this possible with the Simple DOM?
All i can do now it to set the width of the image which doesnt seem to work because the style overwrites it
foreach($content->find('img') as $element) {
$element->width = '750';
}
You can get the image info using: http://php.net/manual/en/function.getimagesize.php
IF you are pulling raw HTML (which I cant tell how you are getting DOM elements in your PHP) you can wget the image, store it tmp, and then get the image info.
In other words, if you need image info via PHP, you need to have it stored and readable
精彩评论