public function DefaultTwigExtension::get_default_image in Opigno training catalog 3.x
Same name and namespace in other branches
- 8 src/TwigExtension/DefaultTwigExtension.php \Drupal\opigno_catalog\TwigExtension\DefaultTwigExtension::get_default_image()
Returns default image.
File
- src/
TwigExtension/ DefaultTwigExtension.php, line 78
Class
- DefaultTwigExtension
- Class DefaultTwigExtension.
Namespace
Drupal\opigno_catalog\TwigExtensionCode
public function get_default_image($type, $title) {
$request = \Drupal::request();
$path = \Drupal::service('module_handler')
->getModule('opigno_catalog')
->getPath();
$title = t('Picture of') . ' ' . $title;
switch ($type) {
case 'course':
$img = '<img src="' . $request
->getBasePath() . '/' . $path . '/img/img_course.png" alt="' . $title . '">';
break;
case 'module':
$img = '<img src="' . $request
->getBasePath() . '/' . $path . '/img/img_module.png" alt="' . $title . '">';
break;
case 'learning_path':
$theme_path = drupal_get_path('theme', 'aristotle');
$img = '<img src="' . $request
->getBasePath() . '/' . $theme_path . '/src/images/content/training.svg" alt="' . $title . '">';
break;
// @TODO Move to the related module.
case 'certificate_image':
$theme_path = drupal_get_path('theme', 'aristotle');
$img = '<img src="' . $request
->getBasePath() . '/' . $theme_path . '/src/images/design/certificate.svg" alt="' . $title . '">';
break;
default:
$img = NULL;
break;
}
return Markup::create($img);
}