<?php
/**
 * The component for displaying branding options in the header
 *
 * @package Reach
 */

use Reach\App\Attachments\Media;
use Reach\App\Fields\SiteOptions;

$options = SiteOptions::getSiteOptions();

?>

<div class="header__branding">
    <div class="header__branding-title">
        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
            <?php
            // check for logo site option
            $logo_id = isset( $options['logo'] ) ? $options['logo'] : false;
            if ( $logo_id ) {
                $logo = Media::getAttachmentByID( $options['logo'] );
                $logo_alt = ! empty( $logo->alt ) ? $logo->alt : get_bloginfo( 'name' );
                echo '<img class="header__branding-logo" src="' . esc_url( $logo->url ) . '" alt="' . $logo_alt . '">';
            } else {
                bloginfo( 'name' );
            }
            ?>
        </a>
    </div>
</div><!-- .site-branding -->
