inject.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * @var News $post
  4. * @var \yii\web\View $this
  5. */
  6. use app\models\base\Image;
  7. use app\models\News;
  8. use yii\helpers\ArrayHelper;
  9. use yii\helpers\Html;
  10. $preview = $post->image;
  11. $retina = $preview->getUrl(Image::SIZE_500x282,"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. $preview = $post->preview;
  20. ?>
  21. <div class="inject" id="<?=$post->uid?>">
  22. <div class="illustration">
  23. <?php if($preview instanceof \app\models\base\Image):?>
  24. <div class="picture-cont-16x9">
  25. <a href="<?=$post->url?>">
  26. <picture class="w-100">
  27. <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
  28. <img src="<?=$bad?>" alt="<?=$post->photo_title?>" class="w-100" loading="lazy">
  29. </picture>
  30. </a>
  31. </div>
  32. <?php else:?>
  33. <div class="picture-cont-16x9">
  34. <a href="<?=$post->url?>">
  35. </a>
  36. </div>
  37. <?php endif;?>
  38. </div>
  39. <div class="meta">
  40. <div class="breadcrumbs">
  41. <?php
  42. echo Html::a("НОВОСТИ", ["/news"], ['class' => "breadcrumb"]);
  43. $topic = $post->getTopics()->andWhere(['show'=>"Y","active"=>1])->one();
  44. if($topic instanceof \app\models\base\NewsTopic) {
  45. echo Html::a($topic->title, ["/news/{$topic->url}"], ['class' => "breadcrumb"]);
  46. }
  47. ?>
  48. </div>
  49. <h2 class="title"><a href="<?=$post->url?>"><?=$post->title?></a></h2>
  50. </div>
  51. </div>