inject.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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->preview;
  11. ?>
  12. <div class="inject" id="<?=$post->uid?>">
  13. <div class="illustration">
  14. <?php if($preview instanceof \app\models\base\Image):?>
  15. <div class="picture-cont-16x9">
  16. <a href="<?=$post->url?>">
  17. <picture class="w-100">
  18. <source srcset="<?=$preview->getUrl(Image::SIZE_680x383,"jpg")?>" media="(min-width: 600px)">
  19. <source srcset="<?=$preview->getUrl(Image::SIZE_680x383,"webp")?>" media="(min-width: 600px)">
  20. <img src="<?=$preview->getUrl(Image::SIZE_680x383)?>" alt="<?=$post->photo_title?>" class="w-100" loading="lazy">
  21. </picture>
  22. </a>
  23. </div>
  24. <?php else:?>
  25. <div class="picture-cont-16x9">
  26. <a href="<?=$post->url?>">
  27. </a>
  28. </div>
  29. <?php endif;?>
  30. </div>
  31. <div class="meta">
  32. <div class="breadcrumbs">
  33. <?php
  34. echo Html::a("НОВОСТИ", ["/news"], ['class' => "breadcrumb"]);
  35. $topic = ArrayHelper::getValue($post->topics,0);
  36. if($topic instanceof \app\models\base\NewsTopic) {
  37. echo Html::a($topic->title, ["news/{$topic->url}"], ['class' => "breadcrumb"]);
  38. }
  39. ?>
  40. </div>
  41. <h2 class="title"><a href="<?=$post->url?>"><?=$post->title?></a></h2>
  42. </div>
  43. </div>