In the attachments edit page i'm trying to use the selected thumbnail instead of the default icon. 99% of the way there but i can't get the attachment's id into the function.
Am i missing something obvious? Help appreciated! Dc.
function set_attachments_icon($icon, $mime = null, $post_id){
$vars = get_defined_vars();
print_r($vars);
echo " ??".$icon."?? ".$post->id.' '.$post_id.' ?? id not getting picked up?';
$thumb_id = get_post_meta($post->ID,'dsv_thumbnail_id', true);
if($thumb_id!=''){
$image_attributes = wp_get_attachment_image_src( $thumb_id );
$icon = $image_attributes[0];
}
return $icon;
}
add_filter('wp_mime_type_icon', 'set_attachments_icon');
apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id );