Source of file GalleryImageExtension.php
Size: 1,459 Bytes - Last Modified: 2021-12-23T10:50:56+00:00
/var/www/docs.ssmods.com/process/src/src/GalleryImageExtension.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php namespace Taitava\SimpleGallery; use SilverStripe\Assets\Image; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\TextField; use SilverStripe\ORM\DataExtension; /** * Class GalleryImageExtension * * @property Image|GalleryImageExtension $owner */ class GalleryImageExtension extends DataExtension { private static $db = [ 'Caption' => 'Text', ]; private static $belongs_many_many = [ 'GalleryPage' => GalleryPage::class, 'GalleryImageGroups' => GalleryImageGroup::class, ]; public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab('Root.Main', new TextField('Caption', 'Kuvateksti'), 'Title'); $fields->removeFieldsFromTab('Root.Main', ['Title', 'Name', 'OwnerID', 'ParentID']); } public function GalleryThumbnail() { return $this->owner->Fit($this->GalleryThumbnailWidth(), $this->GalleryThumbnailHeight()); } public function GalleryThumbnailWidth() { return (int) GalleryImage::config()->get('thumbnail_width'); } public function GalleryThumbnailHeight() { return (int) GalleryImage::config()->get('thumbnail_height'); } public function BootstrapCSSColumnClasses() { if (!GalleryPage::config()->get('use_bootstrap')) return ''; $columns = GalleryImage::config()->get('thumbnail_cols'); $result = ''; foreach ($columns as $type => $size) { if ($result) $result .= ' '; $result .= "col-$type-$size"; //For example: col-md-12 } return $result; } } |