Site icon Hip-Hop Website Design and Development

Find out how to take away picture dimension inline fashion in article and embrace caption

I’m utilizing the next filter to take away the inline fashion within the picture tag when used within the content material editor of the ACF textual content subject:

add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );

perform remove_width_attribute( $html ) peak)="d*"s/', "", $html );
return $html;

BUT it appears to take away the caption in addition to the encompassing markup. How can I take away the inline picture dimension and retain the caption?

That is the markup that WordPress inserts when a picture is positioned into the textual content subject:

div id="attachment_210" fashion="width: 1610px" class="wp-caption 

alignnone"

So you’ll be able to see that the inline fashion makes the container 1610px, and a picture set to 100% would match the fastened width container. I am searching for a method to take away the div markup, which the above filter does, however it additionally removes the caption, which I need to retain