-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
video aspect ratio and new bulk image gallery element
- Loading branch information
1 parent
42b3d70
commit 4c3a5c4
Showing
16 changed files
with
291 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
.textarea.textfield { resize: none; overflow: auto; white-space:nowrap } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?php | ||
|
||
namespace Jellygnite\Elements\Model; | ||
|
||
use DNADesign\Elemental\Models\BaseElement; | ||
use SilverStripe\Assets\Image; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\ORM\FieldType\DBField; | ||
use SilverStripe\ORM\FieldType\DBHTMLText; | ||
use Bummzack\SortableFile\Forms\SortableUploadField; | ||
|
||
use SilverStripe\Dev\Debug; | ||
|
||
/** | ||
* Class ElementGallery | ||
* | ||
* @property string $Content | ||
* | ||
* @method \SilverStripe\ORM\ManyManyList Gallery() | ||
* | ||
* does not need ShowTitle | ||
*/ | ||
class ElementImageGallery extends BaseElement | ||
{ | ||
|
||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $icon = 'font-icon-block-layout-5'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private static $singular_name = 'Image Gallery Element'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private static $plural_name = 'Image Gallery Elements'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $table_name = 'ElementImageGallery'; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $styles = []; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $db = [ | ||
'Content' => 'HTMLText' | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $many_many = [ | ||
'Images' => Image::class | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $many_many_extraFields = array( | ||
'Images' => array( | ||
'SortOrder' => 'Int', | ||
), | ||
); | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $owns = [ | ||
'Images', | ||
]; | ||
|
||
/** | ||
* Set to false to prevent an in-line edit form from showing in an elemental area. Instead the element will be | ||
* clickable and a GridFieldDetailForm will be used. | ||
* | ||
* @config | ||
* @var bool | ||
*/ | ||
private static $inline_editable = false; | ||
|
||
/** | ||
* @param bool $includerelations | ||
* @return array | ||
*/ | ||
public function fieldLabels($includerelations = true) | ||
{ | ||
$labels = parent::fieldLabels($includerelations); | ||
|
||
// $labels['Content'] = _t(__CLASS__.'.ContentLabel', 'Intro'); | ||
$labels['Gallery'] = _t(__CLASS__ . '.ImageGalleryLabel', 'Image Gallery'); | ||
|
||
return $labels; | ||
} | ||
|
||
/** | ||
* @return FieldList | ||
*/ | ||
public function getCMSFields() | ||
{ | ||
$this->beforeUpdateCMSFields(function (FieldList $fields) { | ||
|
||
if ($this->ID) { | ||
$itemField = $fields->dataFieldByName('Images'); | ||
$fields->removeByName('Images'); | ||
$fields->dataFieldByName('Content') | ||
->setRows(8); | ||
|
||
|
||
$fields->addFieldToTab('Root.Main', | ||
|
||
SortableUploadField::create( | ||
'Images', $this->fieldLabel('Images') | ||
)->setRightTitle('Supports bulk image uploads') | ||
); | ||
} | ||
}); | ||
|
||
return parent::getCMSFields(); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getImagesList() | ||
{ | ||
return $this->Images()->sort('SortOrder'); | ||
} | ||
|
||
/** | ||
* @return DBHTMLText | ||
*/ | ||
public function getSummary() | ||
{ | ||
if ($this->Images()->count() == 1) { | ||
$label = ' item'; | ||
} else { | ||
$label = ' items'; | ||
} | ||
return DBField::create_field('HTMLText', $this->Images()->count() . $label)->Summary(20); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
protected function provideBlockSchema() | ||
{ | ||
$blockSchema = parent::provideBlockSchema(); | ||
$blockSchema['content'] = $this->getSummary(); | ||
return $blockSchema; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType() | ||
{ | ||
return _t(__CLASS__.'.BlockType', 'Image Gallery'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
templates/Jellygnite/Elements/Includes/ImageGalleryGrid.ss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="uk-grid uk-flex-top $StyleByLocation(grid) mt-5" data-uk-grid> | ||
<% loop $ImagesList %> | ||
<% if $Me %> | ||
<div class="item uk-text-center<% if $StyleVariant %> $StyleVariant<% end_if %>"> | ||
<div class="item-image-holder" data-mh="mh-image{$Up.ID}"><% if $Me %><img src="$Me.ScaleMaxWidth(640).URL" class="img-fluid" alt="<% if $Me.Title %>$Me.Title.ATT<% else %>$Title.ATT<% end_if %>"><% end_if %></div> | ||
</div> | ||
<% end_if %> | ||
<% end_loop %> | ||
</div> | ||
|
Oops, something went wrong.