2017 © Pedro PelΓ‘ez
 

yii2-extension yii2-gallery

ΠœΠΎΠ΄ΡƒΠ»ΡŒ позволяСт Π·Π°Π³Ρ€ΡƒΠΆΠ°Ρ‚ΡŒ Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ΠΎΠΌ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ

image

deadly299/yii2-gallery

ΠœΠΎΠ΄ΡƒΠ»ΡŒ позволяСт Π·Π°Π³Ρ€ΡƒΠΆΠ°Ρ‚ΡŒ Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ΠΎΠΌ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ

  • Thursday, April 19, 2018
  • by Pavel Archenkov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 1 Versions
  • 20 % Grown

The README.md

Yii2-gallery

Π­Ρ‚ΠΎ ΠΌΠΎΠ΄ΡƒΠ»ΡŒ Π±Ρ‹Π» создан, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π΄Π°Ρ‚ΡŒ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ быстро Π·Π°Π³Ρ€ΡƒΠΆΠ°Ρ‚ΡŒ Π² Π°Π΄ΠΌΠΈΠ½ΠΊΠ΅ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ, Π΄ΠΎΠ±Π°Π²Π»ΡΡ‚ΡŒ Ρ‚ΠΈΡ‚ΡƒΠ»ΡŒΠ½ΠΈΠΊ, описаниС, Π°Π»ΡŒΡ‚Π΅Ρ€Π½Π°Ρ‚ΠΈΠ²Π½Ρ‹ΠΉ тСкст, Π° Ρ‚Π°ΠΊΠΆΠ΅ Π·Π°Π΄Π°Ρ‚ΡŒ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ (Ρ‡Π΅ΠΌ Π²Ρ‹ΡˆΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Ρ‚Π΅ΠΌ Π²Ρ‹ΡˆΠ΅ Π² спискС Π±ΡƒΠ΄Π΅Ρ‚ ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅)., (*1)

Установка

Π’Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠ°Π½Π΄Ρƒ, (*2)

php composer require deadly299/yii2-gallery "@dev"

Или Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π² composer.json, (*3)

"deadly299/yii2-gallery": "@dev",

И Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ, (*4)

php composer update

ΠœΠΈΠ³Ρ€Π°Ρ†ΠΈΡ, (*5)

php yii migrate/up --migrationPath=@vendor/deadly299/yii2-gallery/src/migrations

ΠŸΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ΠΈ настройка

Π’ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΎΠ½Π½Ρ‹ΠΉ Ρ„Π°ΠΉΠ» прилоТСния Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ ΠΌΠΎΠ΄ΡƒΠ»ΡŒ gallery, (*6)

    'modules' => [
        'gallery' => [
            'class' => 'deadly299\gallery\Module',
            'imagesStorePath' => dirname(dirname(__DIR__)).'/frontend/web/images/store', //path to origin images
            'imagesCachePath' => dirname(dirname(__DIR__)).'/frontend/web/images/cache', //path to resized copies
            'graphicsLibrary' => 'GD',
            'placeHolderPath' => '@webroot/images/placeHolder.png',
            'adminRoles' => ['administrator', 'admin', 'superadmin'],
        ],
        //...
    ]

К ΠΌΠΎΠ΄Π΅Π»ΠΈ, ΠΊ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Π°Ρ‚Ρ‚Π°Ρ‡ΠΈΡ‚ΡŒ Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌΡ‹Π΅ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ, добавляСм ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅:, (*7)

    function behaviors()
    {
        return [
            'images' => [
                'class' => 'deadly299\gallery\behaviors\AttachImages',
                'mode' => 'gallery',
                'quality' => 60,
                'galleryId' => 'picture'
            ],
        ];
    }

*mode - Ρ‚ΠΈΠΏ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ. gallery - массовая Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ°, single - ΠΎΠ΄ΠΈΠ½ΠΎΡ‡Π½ΠΎΠ΅ ΠΏΠΎΠ»Π΅, Ссли Π²Π°ΠΌ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ сТатиС Ρ‚ΠΎ установитС quality (0 - 100) Π³Π΄Π΅ 0 - максимальноС сТатиС, 100 - минимальноС сТатиС. galleryId - ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ Π³Π°Π»Π΅Ρ€Π΅ΠΈ, Ссли Ρƒ вас Π²ΠΎΠ·Π½ΠΈΠΊΠ°Π΅Ρ‚ ΠΊΠΎΠ½Ρ„Π»ΠΈΠΊΡ‚ ΠΏΡ€ΠΈ ΠΎΠ΄ΠΈΠ½Π°ΠΊΠΎΠ²Ρ‹Ρ… ΠΈΠΌΡ‘Π½ класса, (*8)

ИспользованиС

Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΌΠΎΠΆΠ½ΠΎ Ρ‚Π°ΠΊΠΆΠ΅, ΠΊΠ°ΠΊ Π½Π°ΠΏΡ€ΡΠΌΡƒΡŽ:, (*9)

$images = $model->getImages();
foreach($images as $img) {
    //retun url to full image
    echo $img->getUrl();

    //return url to proportionally resized image by width
    echo $img->getUrl('300x');

    //return url to proportionally resized image by height
    echo $img->getUrl('x300');

    //return url to resized and cropped (center) image by width and height
    echo $img->getUrl('200x300');

    //return alt text to image
    $img->alt

    //return title to image
    $img->title

    //return description image
    $img->description
}

Π’ΠΈΠ΄ΠΆΠ΅Ρ‚Ρ‹

Π—Π°Π³Ρ€ΡƒΠ·ΠΊΠ° ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΎΠΊ осущСствляСтся Ρ‡Π΅Ρ€Π΅Π· Π²ΠΈΠ΄ΠΆΠ΅Ρ‚. Π”ΠΎΠ±Π°Π²ΡŒΡ‚Π΅ Π² _form.php Π²Π½ΡƒΡ‚Ρ€ΠΈ Ρ„ΠΎΡ€ΠΌΡ‹ CRUDΠ° вашСй ΠΌΠΎΠ΄Π΅Π»ΠΈ. Π’ΠΈΠ΄ΠΆΠ΅Ρ‚Ρƒ ΠΏΠ΅Ρ€Π΅Π΄Π°ΡŽΡ‚ΡΡ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠ΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: model => МодСль ΠΊ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ Π±ΡƒΠ΄ΡƒΡ‚ привязаны ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ, ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ null; previewSize => Ρ€Π°Π·ΠΌΠ΅Ρ€ ΠΏΡ€Π΅Π²ΡŒΡŽ Π·Π°Π³Ρ€ΡƒΠΆΠ΅Π½Π½Ρ‹Ρ… ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ, ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ '140x140'; label => ΠΌΠ΅Ρ‚ΠΊΠ° для Π²ΠΈΠ΄ΠΆΠ΅Ρ‚Π° ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ 'Π˜Π·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅'; fileInputPluginLoading => Π½ΡƒΠΆΠ½ΠΎ Π»ΠΈ ΠΏΠΎΠΊΠ°Π·Ρ‹Π²Π°Ρ‚ΡŒ ΠΈΠ½Π΄ΠΈΠΊΠ°Ρ‚ΠΎΡ€ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ прогрСсса Π² мСстС Π²Π²ΠΎΠ΄Π°, ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ true; fileInputPluginOptions => массив свойств Π²ΠΈΠ΄ΠΆΠ΅Ρ‚Π° kartik/file/fileInput, ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ [];, (*10)

НС Π·Π°Π±ΡƒΠ΄ΡŒΡ‚Π΅ php<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> для Ρ„ΠΎΡ€ΠΌΡ‹., (*11)

=\deadly299\gallery\widgets\Gallery::widget(
    [
        'model' => $model,
        'previewSize' => '50x50',
        'fileInputPluginLoading' => true,
        'fileInputPluginOptions' => []
    ]
); ?>

= \deadly299\gallery\widgets\FrontendGallery::widget([
    'model' => $model,
    'countInput' => 2,
    'classBlockRight' => 'col-sm-12',
    'previewWidth' => '200px',
    'previewHeight' => '150px',
    'informationBlock' => false,
    'otherInputsSettings' => [
        'you-photo' => ['label' => 'Π’Π°ΡˆΠ΅ Ρ„ΠΎΡ‚ΠΎ', 'required' => true],
        'our-work' => ['label' => 'Наша Ρ€Π°Π±ΠΎΡ‚Π°', 'required' => true],
    ],
]) ?>

The Versions

19/04 2018

dev-master

9999999-dev https://github.com/deadly299/yii2-gallery

ΠœΠΎΠ΄ΡƒΠ»ΡŒ позволяСт Π·Π°Π³Ρ€ΡƒΠΆΠ°Ρ‚ΡŒ Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ΠΎΠΌ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ

  Sources   Download

Apache-2.0

The Requires

 

by Avatar Pavel Archenkov

yii2 application images yii2-images deadly299