Jump to content

[SOLVED] remove height attribute from img tag.


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);

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.