<?php
/**
 * The template for displaying attachments
 *
 * @package WordPress
 * @subpackage blazeblog
 * @since BlazeBlog 1.0
 */

get_header(); ?>
<!-- ## content start ## -->
<div id="content">
    <!-- ## content container start ## -->
    <main id="container" class="container" role="main">
        <div class="row">
            <!-- ## primary content start ## -->
            <div id="primary" class="col-md-8 col-sm-12 col-xs-12">
                <?php
				// Start the loop.
				while ( have_posts() ) :
                    the_post();
                ?>
                <div class="row">
                    <div class="col-sm-12">

                        <article id="post-<?php the_ID(); ?>" <?php post_class('post'); ?>>

                            <header class="entry-header col-sm-12">
                                <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
                            </header>

                            <div class="entry-content col-sm-8">
                                <?php blazeblog_excerpt( 'entry-caption' ); ?>

                                <div class="entry-attachment">
                                    <?php
                                            /**
                                             * Filter the default blaze image attachment size.
                                             *
                                             * @since BlazeBlog 1.0
                                             *
                                             * @param string $image_size Image size. Default 'large'.
                                             */
                                            $image_size = apply_filters( 'blazeblog_attachment_size', 'large' );

                                            echo sprintf('<a target="_blank" href="%1$s">%2$s</a>', esc_url( wp_get_attachment_url() ), wp_get_attachment_image( get_the_ID(), $image_size, false, array( 'class' => 'img-responsive' ) ) );
                                    ?>

                                </div>

                                <?php
                                    the_content();
                                    wp_link_pages( array(
                                        'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'blazeblog') . '</span>',
                                        'after'       => '</div>',
                                        'link_before' => '<span>',
                                        'link_after'  => '</span>',
                                        'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'blazeblog') . ' </span>%',
                                        'separator'   => '<span class="screen-reader-text">, </span>',
                                    ) );
                                ?>
                            </div>

                            <footer class="entry-footer col-sm-4">
                                <?php blazeblog_entry_meta(); ?>
                                <?php
                                    // Retrieve attachment metadata.
                                    $metadata = wp_get_attachment_metadata();
                                    if ( $metadata ) {
                                        printf( '<span class="full-size-link"><span class="screen-reader-text">%1$s </span><a target="_blank" href="%2$s">%3$s &times; %4$s</a></span>',
                                            esc_html_x( 'Full size', 'Used before full size attachment link.', 'blazeblog'),
                                            esc_url( wp_get_attachment_url() ),
                                            absint( $metadata['width'] ),
                                            absint( $metadata['height'] )
                                        );
                                    }
                                    $format = 'attachment';
                                    printf( '<span class="entry-format %4$s">%1$s<a target="_blank" href="%2$s">%3$s</a></span>',
                                        sprintf( '<span class="screen-reader-text">%s </span>', _x( 'Format', 'Used before post format.', 'blazeblog' ) ),
                                        esc_url( wp_get_attachment_url() ),
                                        'Attachment',
                                        $format
                                    );
                                ?>
                                <?php
                                    edit_post_link(
                                        sprintf(
                                            /* translators: %s: Name of current post */
                                            __( 'Edit<span class="screen-reader-text"> "%s"</span>', 'blazeblog'),
                                            get_the_title()
                                        ),
                                        '<span class="edit-link">',
                                        '</span>'
                                    );
                                ?>
                            </footer>
                        </article>
                    </div>
                </div>
                <div class="clearfix"></div>
                <nav id="image-navigation" class="navigation post-navigation col-sm-12">
                    <div class="nav-links">
                        <div class="nav-previous">
                            <?php previous_image_link( false, __( 'Previous Image', 'blazeblog') ); ?>
                        </div>
                        <div class="nav-next">
                            <?php next_image_link( false, __( 'Next Image', 'blazeblog') ); ?>
                        </div>
                    </div>
                </nav>
                <div class="clearfix"></div>
                <?php
					// If comments are open or we have at least one comment, load up the comment template.
					if ( comments_open() || get_comments_number() ) {
						comments_template();
					}

					// Parent post navigation.
					the_post_navigation( array(
						'prev_text' => _x( '<span class="meta-nav">Published in</span><span class="post-title">%title</span>', 'Parent post link', 'blazeblog'),
					) );
                    // End the loop.
				endwhile;
                ?>
            </div>
            <!-- ## primary content end ## -->
            <!-- ## sidebar secondary start ## -->
            <?php get_sidebar(); ?>
            <!-- ## sidebar secondary end ## -->
        </div>
    </main>
    <!-- ## content container end ## -->
</div>
<!-- ## content end ## -->
<?php get_footer(); ?>
