RagingEagle Posted January 22, 2007 Share Posted January 22, 2007 Hi,I have a whole bunch of HTML formatted text that is being outputted to my site and in it sometimes images are included but if the image is over 50k in size I don't want it to display that image.How would I go about doing this? I tried some code where it detected the [b]<img src[/b] part but how do I take the actual image, lets say: [b]<img src="theimage.jpg">[/b] how do I just get [b]theimage.jpg[/b] so I can check its file size?Thanks! Link to comment https://forums.phpfreaks.com/topic/35183-detecting-img-tags-in-a-bunch-of-text/ Share on other sites More sharing options...
fert Posted January 22, 2007 Share Posted January 22, 2007 regex Link to comment https://forums.phpfreaks.com/topic/35183-detecting-img-tags-in-a-bunch-of-text/#findComment-166143 Share on other sites More sharing options...
Jessica Posted January 22, 2007 Share Posted January 22, 2007 AKA Regular Expressions. There are some good tutorials for it. Link to comment https://forums.phpfreaks.com/topic/35183-detecting-img-tags-in-a-bunch-of-text/#findComment-166145 Share on other sites More sharing options...
bibby Posted January 22, 2007 Share Posted January 22, 2007 to test for filesize , you'll need the entire path as it is on the filesystem:[code]$file_path=$_SERVER['DOCUMENT_ROOT'].'/images/'.$filename;if(!$size = filesize($file_path)) echo '<!-- I don't recognize '.$file_path.' -->';[/code]It'll return bytesize. Link to comment https://forums.phpfreaks.com/topic/35183-detecting-img-tags-in-a-bunch-of-text/#findComment-166149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.