Put this code in index.php
<img class="img-resposive" src="https://wordpress.stackexchange.com/questions/218286/<?php
$logo=get_option_tree("logo','','true'); // return src of img
$id_logo = get_attachment_id_from_src($logo); // This is custom function for getting image id.
$alt = get_post_meta($id_logo, '_wp_attachment_image_alt', true);// get alt="" from wordpress media.
if ( function_exists( 'get_option_tree') ) :
if( get_option_tree( 'logo')) :
$logo;
else:
echo bloginfo('template_directory') .'/assets/images/logo_vp.png'; // else if option is empty get this image.
endif;
endif;
?>" alt="<?php echo $alt; ?>"/>
Put this function code in functions.php
//get id from image source
function get_attachment_id_from_src ($image_src) {
global $wpdb;
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'";
$id = $wpdb->get_var($query);
return $id;
}
This code is tested. Working fine.