_archive_item.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @var $model \app\models\News
  4. * @var $key
  5. * @var $index
  6. * @var $widget
  7. */
  8. use app\helpers\Transliterator;
  9. use app\models\base\Image;
  10. $preview = $model->image;
  11. $retina = $preview->getUrl(Image::SIZE_680x383,"webp");
  12. $normal = $preview->getUrl(Image::SIZE_320x180,"webp");
  13. $bad = $preview->getUrl(Image::SIZE_320x180,'jpg');
  14. $bad = $bad?$bad:'/images/default.jpg';
  15. if( $retina === false || $normal == false ){
  16. $normal = $bad;
  17. $retina = $bad;
  18. }
  19. /*
  20. После этой даты не выводить фото до подтверждения юриста
  21. */
  22. if( isset( $model->dt_pub ) && !$model->isPhotosOnNews( $model->dt_pub ) ){
  23. $bad = '/images/default.jpg';
  24. $normal = $bad;
  25. $retina = $bad;
  26. };
  27. $normal .= "?v=".$model->rev;
  28. $retina .= "?v=".$model->rev;
  29. $bad .= "?v=".$model->rev;
  30. ?>
  31. <div class="">
  32. <div class="archive-news-item" data-key="<?=$key?>">
  33. <div class="illustration">
  34. <?php if($preview instanceof \app\models\base\Image):?>
  35. <div class="picture-cont-16x9">
  36. <a href="<?=$model->url?>">
  37. <picture class="w-100">
  38. <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
  39. <img src="<?=$bad?>" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" srcset="<?=$normal?>, <?=$retina?> 2x" class="w-100" <?=($index > 2)?'loading="lazy"':''?>>
  40. </picture>
  41. </a>
  42. </div>
  43. <?php else:?>
  44. <div class="picture-cont-16x9">
  45. <a href="<?=$model->url?>">
  46. </a>
  47. </div>
  48. <?php endif;?>
  49. </div>
  50. <div class="meta">
  51. <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
  52. <div class="published_at">
  53. <?=date("d",strtotime($model->dt_pub))." ".mb_strtolower(Transliterator::month(date("n",strtotime($model->dt_pub)))).date(" Y, H:i", strtotime($model->dt_pub))?>
  54. </div>
  55. </div>
  56. </div>
  57. </div>