Jump to content

[SOLVED] remove height attribute from img tag.


joshis

Recommended Posts

Hi,

 

How can I remove the height attribute from my img tag?

 

Source string:

<div ><a href='blah'><img width="7" height="9" alt="" src="images/img.jpg" /></a></div>

 

I need the above content like this.

<div ><a href='blah'><img width="7" alt="" src="images/img.jpg" /></a></div>

 

 

Hello PHP Freaks, I'm a new guy here  8).

 

This question is related, so I'm posting it here:

How can I remove ALL attributes but src from a img tag?

Think I solved it myself:

$html2 = preg_replace('#<img.+?src=[\'"]([^\'"]+)[\'"].*>#i', '<img src="$1">', $html2);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.