protected function CarouselBlock::getCarouselItems in bootstrap simple carousel 8
Returns an active carousel items.
Return value
array|null Items list or null
1 call to CarouselBlock::getCarouselItems()
- CarouselBlock::build in src/
Plugin/ Block/ CarouselBlock.php - Builds and returns the renderable array for this block plugin.
File
- src/
Plugin/ Block/ CarouselBlock.php, line 122
Class
- CarouselBlock
- Provides a 'Bootstrap simple carousel' Block.
Namespace
Drupal\bootstrap_simple_carousel\Plugin\BlockCode
protected function getCarouselItems() {
$items = $this->carouselItemStorage
->getCarouselItems();
if (!empty($items)) {
foreach ($items as &$item) {
$file = $this->entityTypeManager
->getStorage('file')
->load($item->image_id);
$image_style = $this->moduleSettings
->get('image_style');
if (empty($image_style) || $image_style == SettingsForm::ORIGINAL_IMAGE_STYLE_ID) {
$item->image_url = file_url_transform_relative(file_create_url($file
->getFileUri()));
}
else {
$item->image_url = file_url_transform_relative($this->imageStyleService
->load($image_style)
->buildUrl($file
->getFileUri()));
}
if (!empty($item->image_link)) {
$uri = parse_url($item->image_link);
if (empty($uri['host'])) {
if (strpos($item->image_link, '/') !== 0) {
$item->image_link = '/' . $item->image_link;
}
$item->image_link = 'internal:' . $item->image_link;
}
$item->image_link = Url::fromUri($item->image_link);
}
}
}
return $items;
}