<?php
global $redux_demo, $teo_nolazy;
$thumb = get_post_meta($post->ID, '_standard_image', true);
if($thumb == '') {
    $thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
}
$nsfw = get_post_meta($post->ID, '_standard_nsfw', true);
if(is_user_logged_in() ) {
    $userid = wp_get_current_user();
    if(get_user_meta($userid->ID, '_nsfw', true) != 1) {
        $nsfw = 2;
    }

}
$class = 'main-post';
if(is_single() ) {
    $class .= ' post-page';
}
?>
<article <?php post_class($class);?>>
    <?php get_template_part('content', 'header');?>
    <div class="article-content">
        <?php get_template_part('content', 'infobar');?>
        <figure <?php if($nsfw == 1) echo 'class="nsfw"';?>>
            <?php 
            $categories = get_the_category();
            if(count($categories) > 0) { ?>
                <div class="corner-tag green">
                    <?php
                    for($i=0; $i<count($categories); $i++) {
                        echo '<a href="' . get_category_link($categories[$i]->term_id)  . '">' . $categories[$i]->name . '</a>';
                        if($i != count($categories) -1)
                            echo '&nbsp; | &nbsp; ';
                        echo PHP_EOL;
                    } ?>
                </div>
            <?php } 
            if($thumb != '') { 
                $resized = aq_resize($thumb, 635, null, true);
                if($resized == '') { //we can't resize it because it's too small so we show it as-is
                    $resized = $thumb;
                }
                if($teo_nolazy == 1) { ?>
                    <a href="<?php the_permalink();?>"><img src="<?php echo $resized; ?>" alt="<?php the_title();?> "/></a>
                <?php } else { ?>
                    <a href="<?php the_permalink();?>"><img class="lazy" data-original="<?php echo $resized; ?>" alt="<?php the_title();?> "/></a>
                <?php } ?>
            <?php } ?>
            <div class="nsfw_text"><?php _e('Not safe for work', 'Aruna');?></div>
            <div class="nsfw_textreveal"><?php _e('Click here to reveal', 'Aruna');?></div>
        </figure>
    </div>
</article>