I am using IFTTT with Wordpress, so every time that I create a post on reddit, the recipe creates a post on Wordpress.
<div><img src='http://www.thelolempire.com/wp-content/uploads/2016/05/v1yfapih.jpg' style='max-width:600px;' /><br/><div>Tackling dummy</div></div>
The issue is that IFTTT is automatically adding in the style='max-width:600px;'
element which then throws off my responsive template.
So having done some research i have tried to piece together the following code that could filter the element out:
add_filter( 'wp_insert_post_data' , __NAMESPACE__ . '\\filter_post_data' , '99', 2 );
function filter_post_data( $data , $postarr ) {
$data['post_content'] = preg_replace('/(\ style.*)( style=\')/','', $data['post_content']);
return $data;
}
However when I add it to functions.php...everything goes down. Where am I going wrong?