php – Memfilter kelas gambar pada output

Saya berharap ini (ditambahkan ke functions.php) untuk menambahkan “no-shadow” ke semua output gambar dari perpustakaan media … tidak melakukan apa-apa.

function jma_child_get_attachment_image_attributes( $attr, $attach ) {
    $shadowless_imgs = array(9204);
    //if(in_array($attach->ID, $shadowless_imgs))
        $attr['class'] .= ' no-shadow';
    return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'jma_child_get_attachment_image_attributes', 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *