doucan8276 2016-06-01 14:41
浏览 29

删除某个字符后的部分src - IFTTT

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 vmware exsi重置后登不上
    • ¥15 易盾点选的cb参数怎么解啊
    • ¥15 MATLAB运行显示错误,如何解决?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?
    • ¥15 电磁场的matlab仿真
    • ¥15 mars2d在vue3中的引入问题
    • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面