123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /**
- * @var $this \yii\web\View
- * @var $gallery \app\models\front\Gallery
- */
- use yii\helpers\Html;
- $mobile = Yii::$app->deviceDetect->isMobile();
- $maxheight = $mobile?'900':'750';
- if($gallery instanceof \app\models\front\Gallery && count($gallery->getBehavior('galleryBehavior')->getImages())>0 ){
- $c = Yii::$app->acache;
- $c->set('fotorama', true);
- $i=1;
- ob_start();
- foreach($gallery->getBehavior('galleryBehavior')->getImages() as $image){
- $add_cap = ($image->name != '')?", caption: '".$image->name."'":'';
- if( ( $model->type == 2 || $model->type == 6 ) && !$mobile ){
- // лонгрид
- $mainimg = $image->getUrl('large');
- }else{
- $mainimg = $image->getUrl('medium');
- }
- if( $mainimg ){
- ?>
- {img: '<?=$mainimg?>', thumb: '<?=$image->getUrl('small')?>', full:'<?=$image->getUrl('large')?>', id:<?=$i?> <?=$add_cap?>},
- <?
- }
- $i++;
- }
- $ltext = ob_get_contents();
- ob_end_clean();
- /*
- <link href="https://lib.amic.ru/js/fotorama/fotorama.css" rel="stylesheet">
- <script src="https://lib.amic.ru/js/fotorama/fotorama.js" defer></script>
- */
- ?>
- <div id="gallery-<?=$gallery->id?>" class="gallery-wrapper"></div>
- <div class="image-title"><?=$gallery->name?></div>
- <script type="text/javascript">
- window.addEventListener("DOMContentLoaded",function () {
- $('#gallery-<?=$gallery->id?>').fotorama({ width:'100%',maxwidth:1200,maxheight:<?=$maxheight?>,minheight:250, fit: 'contain', thumbheight:70,thumbwidth:94, captions: true,nav:'thumbs', caption: 'overlay', allowfullscreen:'native',transition:'slide', data: [ <?=$ltext?> ] });
- $('#gallery-<?=$gallery->id?>').on('fotorama:show', function (e, fotorama, extra) {
- console.log('cnt+');
- new Image().src = "https://counter.yadro.ru/hit;amicru?r"+escape(document.referrer)+((typeof(screen)=="undefined")?"":";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+";h"+escape(document.title.substring(0,150))+";"+Math.random();
- } );
- });
- </script>
- <?
- }
|