_item_right.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * @var $model \app\models\News
  4. * @var $index integer
  5. */
  6. use app\models\base\Image;
  7. $preview = $model->image;
  8. $retina = $preview->getUrl(Image::SIZE_680x383,"webp");
  9. $normal = $preview->getUrl(Image::SIZE_320x180,"webp");
  10. $bad = $preview->getUrl(Image::SIZE_320x180,'jpg');
  11. $bad = $bad?$bad:'/images/default.jpg';
  12. if( $retina === false || $normal == false ){
  13. $normal = $bad;
  14. $retina = $bad;
  15. }
  16. $normal .= "?v=".$model->rev;
  17. $retina .= "?v=".$model->rev;
  18. $bad .= "?v=".$model->rev;
  19. if( $model->photo_rcol == 'Y' ){
  20. ?>
  21. <div class="card-body mb-0 pb-2">
  22. <?php if($preview instanceof \app\models\base\Image):?>
  23. <div class="picture-cont-16x9">
  24. <a href="<?=$model->url?>">
  25. <picture class="w-100">
  26. <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
  27. <img src="<?=$bad?>" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" srcset="<?=$normal?>, <?=$retina?> 2x" class="w-100" <?=($index > 2)?'loading="lazy"':''?>>
  28. </picture>
  29. </a>
  30. </div>
  31. <?php endif;?>
  32. </div>
  33. <?}?>
  34. <h3>
  35. <?=\yii\helpers\Html::a($model->title,$model->url);?>
  36. <div class="published_at">
  37. <?=($model->dt_pub<date("Y-m-d H:i:s",strtotime("-1 day")))?date("d.m.Y H:i",strtotime($model->dt_pub)):$model->publishedAt?>
  38. <?php
  39. $count=$model->getCommentsAll()->count();
  40. ?>
  41. <?php if($count>0):?>
  42. <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
  43. <?php endif;?>
  44. </div>
  45. </h3>