1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * @var $model \app\models\News
- * @var $key
- * @var $index
- * @var $widget
- */
- use app\models\base\Image;
- $preview = $model->image;
- $retina = $preview->getUrl(Image::SIZE_680x383,"webp");
- $normal = $preview->getUrl(Image::SIZE_320x180,"webp");
- $bad = $preview->getUrl(Image::SIZE_320x180,'jpg');
- $bad = $bad?$bad:'/images/default.jpg';
- if( $retina === false || $normal == false ){
- $normal = $bad;
- $retina = $bad;
- }
- $normal .= "?v=".$model->rev;
- $retina .= "?v=".$model->rev;
- $bad .= "?v=".$model->rev;
- $count=$model->getCommentsAll()->count();
- /*
- После этой даты не выводить фото
- if( isset( $model->dt_pub ) && strtotime( $model->dt_pub ) < strtotime('2015-01-01 00:00:00') ){
- $bad = '/images/default.jpg';
- $normal = $bad;
- $retina = $bad;
- };
- */
- if( isset($index) ){
- $index = $index+1;
- }else{
- static $index = 0;
- }
- ?>
- <div class="">
- <div class="archive-news-item" data-key="<?=$key?>">
- <div class="illustration">
- <?php if($preview instanceof \app\models\base\Image):?>
- <div class="picture-cont-16x9">
- <a href="<?=$model->url?>">
- <picture class="w-100">
- <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
- <img src="<?=$bad?>" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" srcset="<?=$normal?>, <?=$retina?> 2x" class="w-100" <?=($index > 2)?'loading="lazy"':''?>>
- </picture>
- </a>
- </div>
- <?php else:?>
- <div class="picture-cont-16x9">
- <a href="<?=$model->url?>">
- </a>
- </div>
- <?php endif;?>
- </div>
- <div class="meta">
- <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
- <div class="published_at">
- <?=$model->publishedAt?>
- <?php if($count>0):?>
- <span class="commnets"> <svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
- <?php endif;?>
- </div>
- </div>
- </div>
- </div>
- <?php if($index == 4) echo $this->render("@app/views/_etc/banners/archiveAfterFive")?>
|