PhotosFilter.php in Album Photos 8.5
File
src/Plugin/Filter/PhotosFilter.php
View source
<?php
namespace Drupal\photos\Plugin\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
class PhotosFilter extends FilterBase {
public function process($text, $langcode) {
$result = new FilterProcessResult($text);
$text = ' ' . $text . ' ';
$text = preg_replace_callback('/\\[photos=(.*?)\\](.*?)\\[\\/photos\\]/ms', '_photos_filter_process', $text);
$text = mb_substr($text, 1, -1);
$result
->setProcessedText($text);
return $result;
}
public function tips($long = FALSE) {
switch ($long) {
case 0:
return $this
->t('Insert an image: [photos=image]id=55[/photos], insert multiple images: [photos=image]id=55,56,57,58[/photos], insert album: [photos=album]id=10[/photos].');
case 1:
$tip = '<h3>Insert images and albums</h3>';
$item[] = $this
->t('Insert an image: [photos=image]id=55[/photos].');
$item[] = $this
->t('Insert multiple images: [photos=image]id=55,56,57,58,59[/photos].');
$item[] = $this
->t('Optional attributes: align, e.g: [photos=image]id=55|align=left[/photos] or [photos=image]id=55,56,57|align=right[/photos].');
$t1 = [
'#theme' => 'item_list',
'#items' => $item,
'#title' => $this
->t('Images'),
];
$tip .= \Drupal::service('renderer')
->render($t1);
$item = [];
$item[] = $this
->t('Insert album: [photos=album]id=10[/photos]. The default will display the album cover. You can display additional images with the "limit" property.');
$item[] = $this
->t('Optional attributes: align or limit, e.g: [photos=album]id=10|align=left[/photos] or [photos=album]id=10|align=right|limit=5[/photos].');
$t2 = [
'#theme' => 'item_list',
'#items' => $item,
'#title' => $this
->t('Albums'),
];
$tip .= \Drupal::service('renderer')
->render($t2);
$tip .= $this
->t('This is similar to bbcode.');
return $tip;
}
return '';
}
}
Classes
Name |
Description |
PhotosFilter |
Provides a filter to embed image and albums from the photos module. |