You are here

function hook_photoswipe_js_options_alter in PhotoSwipe 8

Same name and namespace in other branches
  1. 8.2 photoswipe.api.php \hook_photoswipe_js_options_alter()
  2. 3.x photoswipe.api.php \hook_photoswipe_js_options_alter()

Provides the ability to override Photoswipe settings passed to JS as Options.

Parameters

array $settings: Default Photoswipe settings array.

1 invocation of hook_photoswipe_js_options_alter()
PhotoswipeAssetsManager::attach in src/PhotoswipeAssetsManager.php
Attach photoswipe assets.

File

./photoswipe.api.php, line 14
Hooks provided by the Photoswipe module.

Code

function hook_photoswipe_js_options_alter(array &$settings) {

  // Disable sharing links.
  $settings['shareEl'] = FALSE;

  // Change or translate share buttons:
  $settings['shareButtons'] = [
    [
      'id' => 'facebook',
      'label' => t('Share on Facebook'),
      'url' => 'https://www.facebook.com/sharer/sharer.php?u={{url}}',
    ],
    [
      'id' => 'twitter',
      'label' => t('Tweet'),
      'url' => 'https://twitter.com/intent/tweet?text={{text}}&url={{url}}',
    ],
    [
      'id' => 'pinterest',
      'label' => t('Pin it'),
      'url' => 'http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}',
    ],
    [
      'id' => 'download',
      'label' => t('Download image'),
      'url' => '{{raw_image_url}}',
      'download' => TRUE,
    ],
  ];
}