This code:
wp_nav_menu( array( 'container' =>false, 'theme_location' => 'main_menu', 'menu_id' => 'main_menu', 'link_before' => get_post_meta($item->object_id, '_menu_item_img'))));
Makes me think that the problem in on the front end when you try to display the values. For readability (and without the extra )):
wp_nav_menu(
array(
'container' =>false,
'theme_location' => 'main_menu',
'menu_id' => 'main_menu',
'link_before' => get_post_meta($item->object_id, '_menu_item_img')
)
);
Essentially, the problem is pure PHP. If you had debugging enabled you’d notice that there is a Notice on the line where that code runs. That is because $item is not defined at that point. $item is defined as the walker callback actually executes but PHP doesn’t notice your variable and wait until later to try to make sense of it. It is processed right there, when it is used.
You will need to create a custom walker for the front end display (something like this).
A filter on the_title might also do it:
function pre_title_wpse_134186($title) {
return 'test'.$title;
}
add_filter('the_title','pre_title_wpse_134186');
wp_nav_menu(
array(
'container' =>false,
'theme_location' => 'main_menu',
'menu_id' => 'main_menu',
)
);
remove_filter('the_title','pre_title_wpse_134186');