View source
<?php
use Drupal\Core\Routing\RouteMatchInterface;
const PHOTOSWIPE_MIN_PLUGIN_VERSION = '4.0.0';
function photoswipe_libraries_info() {
$libraries['photoswipe'] = [
'name' => 'Photoswipe',
'vendor url' => 'https://github.com/dimsemenov/PhotoSwipe',
'download url' => 'https://github.com/dimsemenov/PhotoSwipe/archive/master.zip',
'version arguments' => [
'file' => 'dist/photoswipe.min.js',
'pattern' => '/v([\\d.]+)/',
'lines' => 1,
'cols' => 30,
],
];
return $libraries;
}
function photoswipe_theme() {
return [
'photoswipe_image_formatter' => [
'variables' => [
'item' => NULL,
'display_settings' => [],
'delta' => NULL,
],
'file' => 'photoswipe.theme.inc',
],
'photoswipe_container' => [
'variables' => [],
],
];
}
function photoswipe_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.photoswipe':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('<a href=":url">Photoswipe</a> provides a nice javascript-based display for photo galleries, very sleek on mobile browsers.', [
':url' => 'http://www.photoswipe.com/',
]) . '</p>';
return $output;
}
}
function photoswipe_page_attachments(array &$attachments) {
$is_admin = \Drupal::service('router.admin_context')
->isAdminRoute();
if (\Drupal::config('photoswipe.settings')
->get('photoswipe_always_load_non_admin') && !$is_admin) {
\Drupal::service('photoswipe.assets_manager')
->attach($attachments);
}
}