Page 1 of 1
Help! Remove images by size
Posted: Wed Sep 30, 2009 10:26 am
by kristallaju
OK i have an script which gets feed with simplepie onad out puts it again by removing some predefined words and non acii characters but i want to configure it to remove images smaller than 10x10 px any ideas
Re: Help! Remove images by size
Posted: Wed Sep 30, 2009 1:02 pm
by Jade
If you're taking in the whole feed you can check for <img> tags. Go out and check the filesize or height/width of the image URL.
http://www.php.net/function.getimagesize
Re: Help! Remove images by size
Posted: Wed Sep 30, 2009 2:11 pm
by kristallaju
OK can manage like this
Code: Select all
$string = preg_replace("/<img width\=[\"]1[\"][^>]+>/i","",$string);
but with this is small problem the width attribute must be right after <img or it wont work
Re: Help! Remove images by size
Posted: Wed Sep 30, 2009 2:32 pm
by John Cartwright
It's not a good idea to check the HTML attribute for the width because the HTML attribute is completely optional and can be set to anything regardless of the images true dimensions. Instead, you want to read the image (as jade suggested) with getimagesize() to determine its dimensions.
Re: Help! Remove images by size
Posted: Wed Sep 30, 2009 2:56 pm
by kristallaju
It gets too complicated for me