Oke, berikut adalah solusinya:
Tempelkan kode berikut pada file functions.php theme kalian.
PHP Code:
<?phpfunction it_rmv_broken_img() {
global $post;$images =& get_children( array ('post_parent' => $post->ID,'post_type' => 'attachment','post_mime_type' => 'image','orderby'=> 'rand'));
if ( empty($images) ) {
// no attachments here} else {
foreach ( $images as $attachment ) {
$att_id = $attachment->ID;
$att_title = str_replace('-',' ',$attachment->post_title);
$att_src = wp_get_attachment_image_src( $attachment->ID, 'thumbnail' );
$att_src = $att_src[0];
$link = get_attachment_link( $att_id );
$cek = wp_get_image_editor($att_src);
if(is_wp_error($cek)){
wp_delete_post( $att_id, false );
}
}
}
}add_action('the_post', 'it_rmv_broken_img');?>
Udah, gitu aja. Fungsi ini bekerja dengan sendirinya untuk menghapus broken image di blog agan2 ketika post di load.
Sekian, semoga membantu temen2 pemain wallpaper/semi wallpaper. Semoga bermanfaat! Mohon do'anya semoga target $5000/month tahun ini bisa tercapai.
Wassalamu’alaikum
0 Komentar untuk "Cara menghapus otomatis broken image di Wordpress"