Jump to content

Detecting img tags in a bunch of text?


RagingEagle

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.