I want to print alt or title field image file in custom module Drupal 8. I load file entity use Drupal\file\Entity\File;
I checked core/modules/file/src/Entity/File.php
all public function but not get any function which return title or alt text.
$graph_data = Paragraph::load($graph['target_id']);
$output .= '<div class="swiper-slide">';
$output .= '<div class="slide-inner">';
foreach ($graph_data->field_slider_image as $item) {
$title_img = "Need image title here";
if ($item->entity) {
$slide_uri = $item->entity->getFileUri();
$url = ImageStyle::load('orignal')->buildUrl($slide_uri);
$output .= '<div class="col-md-6"><img src="'.$url.'" class="img-responsive"><h2>'.$title_img.'</h2></div>';
}
}
Please anyone give idea ?
Thankyou