When I upload a photo into the post it turns out like this

<img src="http://localhost:8888/mg/wp-content/uploads/2014/04/sc5.jpg" alt="" width="240" height="240" class="alignnone size-full wp-image-245" />

Is there a way so it will just look like this?

<img src="http://localhost:8888/mg/wp-content/uploads/2014/04/sc5.jpg">
  • Can you give us some more information on why you want to do this? These attributes have a good reason for being there and make sense almost always.
    – kraftner
    Commented Jul 30, 2014 at 15:28
  • I don't want a height of width of my images since all of them are responsive and change in size depending on screen size. I don't need any classes on my images either - the site is really simple. Commented Jul 30, 2014 at 16:22

1 Answer 1


There's a good answer to this question here: http://www.sitepoint.com/wordpress-change-img-tag-html/

His second example is pretty much what you're looking for. Let me know if you need any further help with this.

The main chunk from that answer that concerns you is this:

function image_tag($html, $id, $alt, $title) {
    return preg_replace(array(
            'alt="' . $title . '"'
add_filter('get_image_tag', 'image_tag', 0, 4);

In your case, you'll want the alt="' . $title . '" bit to just be '' like the strings above it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.