public function BootstrapLayout::buildBackgroundMediaImage in Bootstrap Layout Builder 1.x
Helper function to the background media image style.
Parameters
object $media_entity: A media entity object.
object $field_name: The Media entity local video field name.
Return value
string Background media image style.
1 call to BootstrapLayout::buildBackgroundMediaImage()
- BootstrapLayout::build in src/
Plugin/ Layout/ BootstrapLayout.php - Build a render array for layout with regions.
File
- src/
Plugin/ Layout/ BootstrapLayout.php, line 192
Class
- BootstrapLayout
- A layout from our bootstrap layout builder.
Namespace
Drupal\bootstrap_layout_builder\Plugin\LayoutCode
public function buildBackgroundMediaImage($media_entity, $field_name) {
$fid = $media_entity
->get($field_name)->target_id;
$file = File::load($fid);
$background_url = $file
->createFileUrl();
$style = 'background-image: url(' . $background_url . '); background-repeat: no-repeat; background-size: cover;';
return $style;
}