public function ExifSettingsController::showSample in Exif 8
Same name and namespace in other branches
- 8.2 src/Controller/ExifSettingsController.php \Drupal\exif\Controller\ExifSettingsController::showSample()
Create a sample HTML Fragment.
Return value
array HTML Fragment with a sample image and metadata.
1 string reference to 'ExifSettingsController::showSample'
File
- src/
Controller/ ExifSettingsController.php, line 245
Class
- ExifSettingsController
- Class ExifSettingsController manage action of settings pages.
Namespace
Drupal\exif\ControllerCode
public function showSample() {
$sampleImageFilePath = drupal_get_path('module', 'exif') . '/sample.jpg';
$exif = ExifFactory::getExifInterface();
$fullmetadata = $exif
->readMetadataTags($sampleImageFilePath);
$html = '<table class="metadata-table"><tbody>';
foreach ($fullmetadata as $currentSection => $currentValues) {
$html .= '<tr class="metadata-section"><td colspan="2">' . $currentSection . '</td></tr>';
foreach ($currentValues as $currentKey => $currentValue) {
$exif_value = $this
->sanitizeValue($currentValue);
$html .= '<tr class="metadata-row ' . $currentKey . '"><td class="metadata-key">' . $currentKey . '</td><td class="metadata-value">' . $exif_value . '</td></tr>';
}
}
$html .= '</tbody><tfoot></tfoot></table>';
return [
'#metadata' => $html,
'#image_path' => '/' . $sampleImageFilePath,
'#taxo' => '',
'#permissionLink' => '',
'#taxonomyFragment' => '',
'#theme' => 'exif_sample',
'#attached' => [
'library' => [
'exif/exif-sample',
],
],
];
}