Filter – Sort Interface – Post Types Items Custom Thumbnails
This filter will help to change the default thumbnail (either featured image or no image) for a custom post type item within the re-order interface.
apto_reorder_item_thumbnail
Examples:
The following code will return a custom image instead the default thumbnail:
function theme_apto_reorder_item_thumbnail($image_html, $post_ID) { //let's use a custom field called "custom_image" which contain the media we need to show for this $image_url = get_post_meta($post_ID, 'custom_image', TRUE); if($image_url != '') $image_html = '<img src="'. $image_url .'" width="64" alt="" />'; return $image_html; } add_filter('apto_reorder_item_thumbnail', 'theme_apto_reorder_item_thumbnail', 10, 2);
In case the custom_image meta data is not an image url but an attachment, this code can be used instead:
function theme_apto_reorder_item_thumbnail($image_html, $post_ID) { $image_id = get_post_meta($post_ID, 'custom_image', TRUE); $image_data = wp_get_attachment_image_src($image_id, 'thumbnail'); $image_url = $image_data[0]; if($image_url != '') $image_html = '<img src="'. $image_url .'" width="64" alt="" />'; return $image_html; } add_filter('apto_reorder_item_thumbnail', 'theme_apto_reorder_item_thumbnail', 10, 2);
The following code works with the WP E-Commerce product gallery :
function theme_apto_reorder_item_thumbnail($image_html, $post_ID) { //let's use a custom field called "custom_image" which contain the media we need to show for this $image_id = get_post_meta($post_ID, '_wpsc_product_gallery', TRUE); $image_data = wp_get_attachment_image_src($image_id, 'thumbnail'); $image_url = $image_data[0]; if($image_url != '') $image_html = '<img src="'. $image_url .'" width="64" alt="" />'; return $image_html; } add_filter('apto_reorder_item_thumbnail', 'theme_apto_reorder_item_thumbnail', 10, 2);
*This code should be used within the theme or a custom plugin.
API Index