Help! Remove images by size
Moderator: General Moderators
-
kristallaju
- Forum Newbie
- Posts: 5
- Joined: Wed Sep 30, 2009 10:22 am
Help! Remove images by size
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
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
http://www.php.net/function.getimagesize
-
kristallaju
- Forum Newbie
- Posts: 5
- Joined: Wed Sep 30, 2009 10:22 am
Re: Help! Remove images by size
OK can manage like this
but with this is small problem the width attribute must be right after <img or it wont work
Code: Select all
$string = preg_replace("/<img width\=[\"]1[\"][^>]+>/i","",$string);
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Help! Remove images by size
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.
-
kristallaju
- Forum Newbie
- Posts: 5
- Joined: Wed Sep 30, 2009 10:22 am
Re: Help! Remove images by size
It gets too complicated for me