Code Monkey home page Code Monkey logo

yii2-fotorama-widget's Introduction

DEPRECATED

Unfortunately, original Fotorama gallery is no longer maintained. You still can use this extension if fotorama fits your project. Check github thread for alternatives.

Fotorama Yii2 widget

This yii2 extension is a wrapper for the powerful jQuery gallery Fotorama.

Latest Stable Version Total Downloads Latest Unstable Version License

Scrutinizer Code Quality Code Coverage Build Status Code Climate

Installation

Install this extension using composer.

composer require metalguardian/yii2-fotorama-widget

You should have configured asset-packagist repository in your project's composer.json or installed fxp/composer-asset-plugin plugin. For more information see Yii2 bower/npm assets manual

Usage

First way:

    <?php 
    $fotorama = \metalguardian\fotorama\Fotorama::begin(
        [
            'options' => [
                'loop' => true,
                'hash' => true,
                'ratio' => 800/600,
            ],
            'spinner' => [
                'lines' => 20,
            ],
            'tagName' => 'span',
            'useHtmlData' => false,
            'htmlOptions' => [
                'class' => 'custom-class',
                'id' => 'custom-id',
            ],
        ]
    ); 
    ?>
        <img src="http://s.fotorama.io/1.jpg">    
        <img src="http://s.fotorama.io/2.jpg">
        <img src="http://s.fotorama.io/3.jpg">
        <img src="http://s.fotorama.io/4.jpg">
        <img src="http://s.fotorama.io/5.jpg">
    <?php \metalguardian\fotorama\Fotorama::end(); ?>

Second way:

    <?php 
    echo \metalguardian\fotorama\Fotorama::widget(
        [
            'items' => [
                ['img' => 'http://s.fotorama.io/1.jpg', 'id' => 'id-one',],
                ['img' => 'http://s.fotorama.io/2.jpg',],
                ['img' => 'http://s.fotorama.io/3.jpg',],
                ['img' => 'http://s.fotorama.io/4.jpg',],
            ],
            'options' => [
                'nav' => 'thumbs',
            ]
        ]
    ); 
    ?>

To use CDNJS put this before run widget, will be used current version:

    <?php \metalguardian\fotorama\Fotorama::$useCDN = true; ?>

Or select custom version:

    <?php \metalguardian\fotorama\Fotorama::$useCDN = '4.5.0'; ?>

To setup default Fotorama widget options to all galleries on page:

    <?php 
    \metalguardian\fotorama\Fotorama::setDefaults(
        [
            'nav' => 'thumbs',
            'spinner' => [
                'lines' => 20,
            ],
            'loop' => true,
            'hash' => true,
        ]
    );
    ?>

For complete documentation of Fotorama and all widget options please refer to the official Fotorama page

License

yii2-fotorama-widget is released under the MIT License. See the bundled LICENSE for details.

yii2-fotorama-widget's People

Contributors

elisdn avatar metalguardian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

yii2-fotorama-widget's Issues

The file or directory to be published does not exist in yii2 v.2.0.13

After yii2 update to version 2.0.13, need change Asset url in FotoramaAsset.php file from "public $sourcePath = '@vendor/bower/fotorama'" to "public $sourcePath = '@vendor/bower-asset/fotorama'". After that, issues with "The file or directory to be published does not exist:" must gone. Sorry for my English :)

add a custom class to htmlOptions

I use the widget in my project by next way:

...
echo Fotorama::widget(
    [
        'items' => $images,
        'options' => [
            'nav' => 'thumbs',
            'allowfullscreen' => 'true',
            'fit' => 'scaledown',
        ],
    ]
);
...

After that I get <div class="fotorama fotorama1534314224724">...</div> block, which contains all the data.

Now, I would like to add some extra class to the div-block. So, change my code a little:

echo Fotorama::widget(
    [
        'items' => $images,
        'options' => [
            'nav' => 'thumbs',
            'allowfullscreen' => 'true',
            'fit' => 'scaledown',
        ],
        'htmlOptions' => [
            'class' => 'pull-right-md',
        ],
    ]
);

As a result of we have <div class="pull-right-md">...</div> block. Without futurama and fotorama1534314224724. So, I can add the first one by adding it to config:

'htmlOptions' => [
    'class' => 'fotorama pull-right-md',
],

but what should I do with the last one?! As I can realize its name is generated on fly, that is why I can't just add it to config.

empty gallery if js is off (bad for search engine robots?)

Hello!
Thanks for your widget!

Its handy to prepare array of images in code and use your widget by "second way".
But in this case images adding by script after load. And if i turn off javascript the gallery is empty, but fotorama has graceful degradation principles. I think you should generates image tags in widget for this case. And after all just init fotorama.

I think it's not good for SEO, isn't it?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.