// Insert style to display page's thumbnail
$item_style = '';
if ($depth == 0 && has_post_thumbnail((int)$object->object_id)) {
- $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id((int)$object->object_id), 'medium');
- $item_style .= "<style>#menu-item-".$object->ID." > .dropdown:before { background-image: url('".$thumbnail[0]."');</style>";
+ $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id((int)$object->object_id), 'bpla-drop-down');
+ //$item_style .= "<style>#menu-item-".$object->ID." > .dropdown:before { background-image: url('".$thumbnail[0]."');</style>";
}
//$output .= ( 0 == $depth ) ? '<li class="divider"></li>' : '';
$classes = empty( $object->classes ) ? array() : (array) $object->classes;
if ( in_array( 'divider', $classes ) ) {
$item_html = preg_replace( '/<a[^>]*>( .* )<\/a>/iU', '', $item_html );
}
- if ($item_style)
+ if ($item_style) {
$output .= $item_style;
+ }
+ if ($depth == 0 && has_post_thumbnail((int)$object->object_id) && $object->has_children) {
+ $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id((int)$object->object_id), 'bpla-drop-down');
+ $item_html .= '<script>var img_for_menu_' . $object->ID . ' = "' . $thumbnail[0] . '";</script>';
+ //$item_html .= '<pre>' . print_r($object, true) . '</pre>';
+ }
$output .= $item_html;
}
function start_lvl( &$output, $depth = 0, $args = array() ) {
- $output .= "\n<ul class=\"sub-menu dropdown\">\n";
+ if ($depth == 0) {
+ $output .= "\n<ul class=\"sub-menu dropdown\">\n";
+ $output .= "\n<li class=\"image-placeholder\" style=\"position: absolute; left: 20px; top: 22px;width: 219px;height: 169px;border-bottom:none;border: 4px solid green;\">";
+ $output .= "</li>\n";
+ }
}
}
}
add_action('thematic_searchloop', 'mytheme_search_loop');
+add_action('after_setup_theme', 'bpla_theme_setup');
+function bpla_theme_setup()
+{
+ add_image_size( 'bpla-drop-down', 219, 169, true );
+}
// End of the Contextual/Highlight Search functions
?>
$(this).toggleClass('open');
$(this).siblings('ul').toggleClass('open');
});
+ $('.top-bar-section').find('ul.sub-menu.dropdown').each(function (){
+ var menuImg = $(this).parent('li').prop('id');
+ var menuNum = menuImg.match(/\d+/)[0];
+ var menuImgSrc = 'img_for_menu_' + menuNum;
+ $(this).find('li.image-placeholder').html('<img src="' + eval(menuImgSrc) + '">');
+ console.log('ul = ' + menuImg);
+ console.log('menu-id = ' + menuNum);
+ });
});
$(this).toggleClass('open');
$(this).siblings('ul').toggleClass('open');
});
+ $('.top-bar-section').find('ul.sub-menu.dropdown').each(function (){
+ var menuImg = $(this).parent('li').prop('id');
+ var menuNum = menuImg.match(/\d+/)[0];
+ var menuImgSrc = 'img_for_menu_' + menuNum;
+ $(this).find('li.image-placeholder').html('<img src="' + eval(menuImgSrc) + '">');
+ console.log('ul = ' + menuImg);
+ console.log('menu-id = ' + menuNum);
+ });
});