[Resolved] Removing Width + Height Attributes from Featured Images

Home Forums Support [Resolved] Removing Width + Height Attributes from Featured Images

Home Forums Support Removing Width + Height Attributes from Featured Images

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #523202
    Janine

    I found this gist on Github:

    /*————————————————————————————–*/
    /* Remove width/height attributes from featured image */
    /*————————————————————————————–*/
    function remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) {
    $html = preg_replace( ‘/(width|height)=\”\d*\”\s/’, “”, $html );
    return $html;
    }
    add_filter( ‘post_thumbnail_html’, ‘remove_thumbnail_dimensions’, 10, 3 );

    After I implement it, how would I know if it worked?

    Thank you!

    #523380
    Tom
    Lead Developer
    Lead Developer

    You can right click the image and click “Inspect”. It will show you the HTML for the image.

    #523538
    Janine

    Thanks, Tom.

    #523819
    Tom
    Lead Developer
    Lead Developer

    No problem!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.