_main_view_item_slider.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @var $model \app\models\News
  4. * @var $key
  5. * @var $index
  6. * @var $widget
  7. */
  8. use app\models\base\Image;
  9. use app\models\PhotoFilter;
  10. $brightness = Yii::$app->deviceDetect->isMobile()?85:100;
  11. $mfilter = new PhotoFilter();
  12. $filter = $mfilter->findOne($model->id);
  13. if( !$filter ){
  14. $filter = new stdClass();
  15. $filter->brightness = $brightness;
  16. $filter->saturate = 100;
  17. $filter->contrast = 100;
  18. $filter->opacity = 0.5;
  19. }
  20. $sstr = 'style="filter: saturate('.$filter->saturate.'%) brightness('.$filter->brightness.'%) contrast('.$filter->contrast.'%);"';
  21. $preview = $model->preview;
  22. $className = 'main';
  23. ?>
  24. <div class="news-sitem <?=$className?> col-md-12" data-key="<?=$key?>">
  25. <?php if($preview instanceof Image ):?>
  26. <div class="picture-cont-16x9" >
  27. <a href="<?=$model->url?>" title="<?=htmlentities($model->title,ENT_QUOTES)?>">
  28. <picture class="w-100" id="fimgb<?=$index?>" >
  29. <img src="<?=$preview->getUrl(Image::SIZE_841x473,'jpg')?>?v=<?=$model->rev?>" srcset="<?=$preview->getUrl(Image::SIZE_841x473,'webp')?>?v=<?=$model->rev?> 841w,<?=$preview->getUrl(Image::SIZE_320x180)?>?v=<?=$model->rev?> 320w,<?=$preview->getUrl(Image::SIZE_500x282)?>?v=<?=$model->rev?> 500w,<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?> 680w" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" class="w-100" loading="lazy" id='mainphoto' <?=$sstr?>>
  30. </picture>
  31. </a>
  32. </div>
  33. <div class="meta">
  34. <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
  35. <?php if($className!="low"): ?><div class="lead"><?=$model->lid?></div><?php endif;?>
  36. <div class="published_at">
  37. <?=$model->publishedAt?> <?=date("H:i",strtotime($model->dt_pub))?>
  38. <?php if($model->comments=="Y"):?>
  39. <?php
  40. $count=$model->getCommentsAll()->count();
  41. ?>
  42. <?php if($count>0):?>
  43. <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
  44. <?php endif;?>
  45. <?php endif;?>
  46. </div>
  47. </div>
  48. <?php endif;?>
  49. <span class="slpager slinner">
  50. <?
  51. for( $i = 0; $i < $elcount; $i++ ){
  52. ?>
  53. <span class="slider-indicator<?=$index == $i?' active':' '?>"></span>
  54. <?
  55. }
  56. ?>
  57. </span>
  58. <style>
  59. #fimgb<?=$index?>::after{
  60. background:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,<?=$filter->opacity?>)) !important;
  61. }
  62. #fimgb<?=$index?>{
  63. filter:brightness(100%);
  64. }
  65. </style>
  66. </div>