<?php | |
add_action( 'media_send_to_editor', 'mxp_before_insert_media'); | |
function mxp_before_insert_media($html, $id, $attachment) { | |
//此方法針對全媒體,不只有圖片 | |
$html = preg_replace('/width="(\d+)"/i', 'width="auto"', $html); | |
$html = preg_replace('/height="(\d+)"/i', 'height="auto"', $html); | |
return $html; | |
} |
把
<?php
以下整段,貼到正在使用的佈景主題下的 functions.php 最後面即可
沒有留言:
張貼留言