function social_landing_page_preprocess_paragraph in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 8 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 8.2 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 8.3 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 8.4 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 8.5 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 8.7 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 8.8 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 10.3.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 10.0.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 10.1.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
- 10.2.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_paragraph()
Prepares variables for the paragraph.
File
- modules/
social_features/ social_landing_page/ social_landing_page.module, line 158 - The Social landing page module.
Code
function social_landing_page_preprocess_paragraph(&$variables) {
/** @var \Drupal\paragraphs\Entity\Paragraph $entity */
$entity = $variables['elements']['#paragraph'];
$bundle = $entity
->bundle();
switch ($bundle) {
case 'hero':
// Add the hero styled image.
$image_style = 'social_landing_hero';
$image_field = "field_{$bundle}_image";
if ($entity
->hasField($image_field) && !empty($entity->{$image_field}->entity)) {
$variables['hero_styled_image_url'] = ImageStyle::load($image_style)
->buildUrl($entity->{$image_field}->entity
->getFileUri());
}
break;
case 'hero_small':
// Add the hero styled image.
$image_style = 'social_landing_hero_small';
$image_field = "field_{$bundle}_image";
if ($entity
->hasField($image_field) && !empty($entity->{$image_field}->entity)) {
$variables['hero_small_styled_image_url'] = ImageStyle::load($image_style)
->buildUrl($entity->{$image_field}->entity
->getFileUri());
}
break;
}
}