Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add limit of images displayed #29

Merged
merged 1 commit into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion contao/dca/tl_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
[
'fbi_inherit' => '',
'fbi_disable' => '',
'fbi_choose' => 'fbiSRC,sortBy,fbiImgMode,fbiTimeout,fbiSpeed,fbiEnableNav,fbiNavClick,fbiNavPrevNext,
'fbi_choose' => 'fbiSRC,sortBy,fbiLimit,fbiImgMode,fbiTimeout,fbiSpeed,fbiEnableNav,fbiNavClick,fbiNavPrevNext,
fbiCenterX,fbiCenterY,fbiTemplate;',
]
);
Expand Down Expand Up @@ -100,6 +100,17 @@
],
'sql' => "varchar(32) NOT NULL default ''",
],
'fbiLimit' => [
'label' => &$GLOBALS['TL_LANG']['tl_content']['fbiLimit'],
'default' => 0,
'exclude' => true,
'inputType' => 'text',
'eval' => [
'rgxp' => 'digit',
'tl_class' => 'w50',
],
'sql' => "varchar(10) NOT NULL default 0",
],
'fbiImgMode' => [
'label' => &$GLOBALS['TL_LANG']['tl_page']['fbiImgMode'],
'default' => 'paMultiple',
Expand Down
8 changes: 8 additions & 0 deletions contao/languages/de/tl_page.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<source>Select the mode for the background images.</source>
<target>Wählen Sie einen Bildmodus aus.</target>
</trans-unit>
<trans-unit id="tl_page.fbiLimit.0">
<source>Number of Image</source>
<target>Anzahl Bilder</target>
</trans-unit>
<trans-unit id="tl_page.fbiLimit.1">
<source>"0" will show all the background images.</source>
<target>Bei "0" werden alle Bilder angezeigt.</target>
</trans-unit>
<trans-unit id="tl_page.single.0">
<source>Single image</source>
<target>Einzelbild</target>
Expand Down
6 changes: 6 additions & 0 deletions contao/languages/en/tl_page.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<trans-unit id="tl_page.fbiImgMode.1">
<source>Select the mode for the background images.</source>
</trans-unit>
<trans-unit id="tl_page.fbiLimit.0">
<source>Number of Image</source>
</trans-unit>
<trans-unit id="tl_page.fbiLimit.1">
<source>"0" will show all the background images.</source>
</trans-unit>
<trans-unit id="tl_page.single.0">
<source>Single image</source>
</trans-unit>
Expand Down
6 changes: 6 additions & 0 deletions src/Fbi/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function generate(\PageModel $page, \LayoutModel $layout, \PageRegular $p
$this->speed = $this->pageWithBackgrounds->fbiSpeed;
$this->timeout = $this->pageWithBackgrounds->fbiTimeout;
$this->order = $this->pageWithBackgrounds->fbiOrder;
$this->fbiLimit = (int) $this->pageWithBackgrounds->fbiLimit;
$this->nav = (int) $this->pageWithBackgrounds->fbiEnableNav;
$this->navClick = (int) $this->pageWithBackgrounds->fbiNavClick;
$this->navPrevNext = (int) $this->pageWithBackgrounds->fbiNavPrevNext;
Expand Down Expand Up @@ -215,6 +216,11 @@ public function compile(\PageModel $page)
}
}

// Limited images
if ($this->fbiLimit && 0 != $this->fbiLimit && count($images) > $this->fbiLimit) {
$images = array_slice($images, 0, $this->fbiLimit);
}

$images = array_values($images);
$maxWidth = $GLOBALS['TL_CONFIG']['maxImageWidth'];
$imageObjects = [];
Expand Down