class ImageLazyLoadController
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/image_lazy_load_test/src/Controller/ImageLazyLoadController.php \Drupal\image_lazy_load_test\Controller\ImageLazyLoadController
- 10 core/modules/system/tests/modules/image_lazy_load_test/src/Controller/ImageLazyLoadController.php \Drupal\image_lazy_load_test\Controller\ImageLazyLoadController
The ImageLazyLoadController class.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\image_lazy_load_test\Controller\ImageLazyLoadController extends \Drupal\Core\Controller\ControllerBase
Expanded class hierarchy of ImageLazyLoadController
File
-
core/
modules/ system/ tests/ modules/ image_lazy_load_test/ src/ Controller/ ImageLazyLoadController.php, line 10
Namespace
Drupal\image_lazy_load_test\ControllerView source
class ImageLazyLoadController extends ControllerBase {
/**
* Render an image using image theme.
*
* @return array
* The render array.
*/
public function renderImage() {
$images['with-dimensions'] = [
'#theme' => 'image',
'#uri' => '/core/themes/olivero/logo.svg',
'#alt' => 'Image lazy load testing image',
'#prefix' => '<div id="with-dimensions">',
'#suffix' => '</div>',
'#width' => '50%',
'#height' => '50%',
];
$images['without-dimensions'] = [
'#theme' => 'image',
'#uri' => '/core/themes/olivero/logo.svg',
'#alt' => 'Image lazy load testing image without dimensions',
'#prefix' => '<div id="without-dimensions">',
'#suffix' => '</div>',
];
$images['override-loading-attribute'] = [
'#theme' => 'image',
'#uri' => '/core/themes/olivero/logo.svg',
'#alt' => 'Image lazy load test loading attribute can be overridden',
'#prefix' => '<div id="override-loading-attribute">',
'#suffix' => '</div>',
'#width' => '50%',
'#height' => '50%',
];
$images['override-loading-attribute']['#attributes']['loading'] = 'eager';
return $images;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.