mirror of
https://github.com/a2nt/silverstripe-webpack.git
synced 2024-10-22 17:05:31 +02:00
FIX: minor fixtures
This commit is contained in:
parent
878feb96a3
commit
b6c20dbf8c
app
src
templates/Dynamic/Elements/Image/Elements
@ -48,25 +48,23 @@ class ElementImageWidget extends DataExtension
|
|||||||
{
|
{
|
||||||
parent::updateCMSFields($fields);
|
parent::updateCMSFields($fields);
|
||||||
|
|
||||||
$fields->insertBefore(
|
$fields->removeByName(['ImageLinkID', 'Resize']);
|
||||||
'Image',
|
|
||||||
LinkField::create('ImageLinkID', 'Link')
|
$fields->push(LinkField::create('ImageLinkID', 'Link'));
|
||||||
);
|
|
||||||
|
|
||||||
$this->owner->ImageHeight = $this->getHeight();
|
$this->owner->ImageHeight = $this->getHeight();
|
||||||
|
|
||||||
$heights = Config::inst()->get(__CLASS__, 'available_heights');
|
$heights = Config::inst()->get(__CLASS__, 'available_heights');
|
||||||
$widths = Config::inst()->get(__CLASS__, 'available_widths');
|
$widths = Config::inst()->get(__CLASS__, 'available_widths');
|
||||||
|
|
||||||
$fields->replaceField('Resize', CheckboxField::create(
|
$fields->push(CheckboxField::create(
|
||||||
'Resize',
|
'Resize',
|
||||||
'Would you like to scale image?'
|
'Would you like to scale image?'
|
||||||
));
|
));
|
||||||
|
|
||||||
if (count($heights)) {
|
if (count($heights)) {
|
||||||
$fields->removeByName(['ManualWidth','ImageWidth',]);
|
$fields->removeByName(['ManualWidth','ImageWidth', 'ImageHeight']);
|
||||||
$fields->replaceField(
|
$fields->push(
|
||||||
'ImageHeight',
|
|
||||||
CompositeField::create(
|
CompositeField::create(
|
||||||
DropdownField::create(
|
DropdownField::create(
|
||||||
'ImageHeight',
|
'ImageHeight',
|
||||||
@ -140,4 +138,15 @@ class ElementImageWidget extends DataExtension
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onBeforeWrite()
|
||||||
|
{
|
||||||
|
$title = $this->owner->getField('Title');
|
||||||
|
$img = $this->owner->Image();
|
||||||
|
if (!$title && $img) {
|
||||||
|
$this->owner->setField('Title', $img->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::onBeforeWrite();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,4 +46,25 @@ class BannerWidget extends Widget
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $_random;
|
||||||
|
public function Random()
|
||||||
|
{
|
||||||
|
if (!$this->_random) {
|
||||||
|
$this->_random = self::get()->filter('Enabled', true)->sort('RAND()')->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_random;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onBeforeWrite()
|
||||||
|
{
|
||||||
|
$title = $this->getField('Title');
|
||||||
|
$img = $this->Image();
|
||||||
|
if (!$title && $img) {
|
||||||
|
$this->setField('Title', $img->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::onBeforeWrite();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="image-element__image<% if $Resize %><% if $Height %> height{$Height}<% end_if %><% if $Width %> width{$Width}<% end_if %><% end_if %>">
|
<div class="image-element__image<% if $Resize %><% if $Height %> height{$Height}<% end_if %><% if $Width %> width{$Width}<% end_if %><% end_if %>">
|
||||||
<img
|
<img
|
||||||
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
|
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
|
||||||
data-lazy-src="$ImageResized.URL" class="img-responsive" alt="$Title.ATT"
|
data-lazy-src="$ImageResized.URL" class="img-responsive" alt="$Title"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
Loading…
Reference in New Issue
Block a user