Commit 9af7d68e6d88dfda8dc9218486a4b189ac51bd32
1 parent
9f58b40c
-Image alts in gallery
Showing
2 changed files
with
39 additions
and
31 deletions
Show diff stats
common/models/Gallery.php
frontend/views/site/gallery.php
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * @var View $this | |
| 3 | + * @var View $this | |
| 4 | 4 | * @var Image[] $images |
| 5 | 5 | */ |
| 6 | 6 | |
| ... | ... | @@ -10,42 +10,49 @@ |
| 10 | 10 | use yii\web\View; |
| 11 | 11 | |
| 12 | 12 | PhotoswipeAsset::register($this); |
| 13 | - | |
| 14 | -$seo = \Yii::$app->get('seo'); | |
| 15 | -$this->title = \Yii::t('app', 'Галерея'); | |
| 16 | -$this->params[ 'breadcrumbs' ][] = $this->title; | |
| 13 | + | |
| 14 | + $seo = \Yii::$app->get('seo'); | |
| 15 | + $this->title = \Yii::t('app', 'Галерея'); | |
| 16 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div id="content"> |
| 20 | - <div class="container"> | |
| 21 | - <div class="row"> | |
| 22 | - <div class="col-md-12"> | |
| 23 | - <div class="heading"> | |
| 24 | - <h2>Галерея</h2> | |
| 25 | - </div> | |
| 26 | - <div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery"> | |
| 27 | - <?php foreach ($images as $image) { | |
| 28 | - if (file_exists(\Yii::getAlias('@storage/' . $image->id . '_' . $image->fileHash . '.' . $image->extension))) { | |
| 29 | - ?> | |
| 30 | - <figure class="reviews_gallery"> | |
| 31 | - <a href="<?= $image->getUrl() ?>" itemprop="contentUrl" data-size="<?= getimagesize( | |
| 32 | - $image->getPath() | |
| 33 | - )[ 0 ] . 'x' . getimagesize( | |
| 34 | - $image->getPath() | |
| 35 | - )[ 1 ] ?>"> | |
| 36 | - <img src="<?= ImageHelper::set($image->getPath()) | |
| 37 | - ->cropResize(500, 325) | |
| 38 | - ->render() ?>" itemprop="thumbnail" alt=""/> | |
| 39 | - </a> | |
| 40 | - </figure> | |
| 41 | - <?php | |
| 42 | - } | |
| 43 | - } | |
| 20 | + <div class="container"> | |
| 21 | + <div class="row"> | |
| 22 | + <div class="col-md-12"> | |
| 23 | + <div class="heading"> | |
| 24 | + <h2>Галерея</h2> | |
| 25 | + </div> | |
| 26 | + <div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery"> | |
| 27 | + <?php foreach ($images as $image) { | |
| 28 | + if (file_exists( | |
| 29 | + \Yii::getAlias('@storage/' . $image->id . '_' . $image->fileHash . '.' . $image->extension) | |
| 30 | + )) { | |
| 44 | 31 | ?> |
| 45 | - </div> | |
| 46 | - </div> | |
| 32 | + <figure class="reviews_gallery"> | |
| 33 | + <a href="<?= $image->getUrl() ?>" itemprop="contentUrl" data-size="<?= getimagesize( | |
| 34 | + $image->getPath() | |
| 35 | + )[ 0 ] . 'x' . getimagesize( | |
| 36 | + $image->getPath( | |
| 37 | + ) | |
| 38 | + )[ 1 ] ?>"> | |
| 39 | + <img src="<?= ImageHelper::set($image->getPath()) | |
| 40 | + ->cropResize(500, 325) | |
| 41 | + ->render() ?>" itemprop="thumbnail" alt="<?php | |
| 42 | + if (!empty($image->lang)) { | |
| 43 | + echo $image->lang->alt; | |
| 44 | + } | |
| 45 | + ?>"/> | |
| 46 | + </a> | |
| 47 | + </figure> | |
| 48 | + <?php | |
| 49 | + } | |
| 50 | + } | |
| 51 | + ?> | |
| 47 | 52 | </div> |
| 53 | + </div> | |
| 48 | 54 | </div> |
| 55 | + </div> | |
| 49 | 56 | </div> |
| 50 | 57 | |
| 51 | 58 | <div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"> | ... | ... |