1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need php help Remove images by size

Discussion in 'PHP & Perl' started by kaidoristm, Sep 29, 2009.

  1. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    So im not very good with php still learning:) so could use some help here.
    So question is how to remove image if image size is smaller than 10x10 px ?
     
  2. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    SO managed to strip out all tags like this
    PHP:
     <?php
    $string 
    preg_replace("/<img[^>]+>/i","",$string);
    ?>
    It removes all image tags what i want is to remove only those tags with attribute width="1"
     
    Last edited: Sep 30, 2009
  3. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    Almoust got it
    PHP:
    <?php
    $string 
    preg_replace("/<img width\=[\"]1[\"][^>]+>/i","",$string);
    ?>
    but there is small problem with this version it removes image only then if width is right after <img
     
    Last edited: Sep 30, 2009
  4. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    Isnt that great thread ill ask myself and ill answer myself :)
    Finally i got it thanks everyone for answers
    PHP:
    <?php
    $string 
    preg_replace('/<img[^>]+width="1"[^>]*>/i'null,$string);
    ?>