class SlickFormatter in Slick Carousel 7.3
Same name and namespace in other branches
- 8.2 src/SlickFormatter.php \Drupal\slick\SlickFormatter
- 8 src/SlickFormatter.php \Drupal\slick\SlickFormatter
Implements SlickFormatterInterface.
Hierarchy
- class \Drupal\blazy\BlazyManagerBase implements BlazyManagerInterface
- class \Drupal\blazy\BlazyManager
- class \Drupal\blazy\BlazyFormatter
- class \Drupal\slick\SlickFormatter implements SlickFormatterInterface
- class \Drupal\blazy\BlazyFormatter
- class \Drupal\blazy\BlazyManager
Expanded class hierarchy of SlickFormatter
1 file declares its use of SlickFormatter
- slick.module in ./
slick.module - Slick carousel integration, the last carousel you'll ever need.
File
- src/
SlickFormatter.php, line 11
Namespace
Drupal\slickView source
class SlickFormatter extends BlazyFormatter implements SlickFormatterInterface {
/**
* {@inheritdoc}
*/
public function buildSettings(array &$build, $items, $entity) {
$settings =& $build['settings'];
// Prepare integration with Blazy.
$settings['item_id'] = 'slide';
$settings['namespace'] = 'slick';
// Pass basic info to parent::buildSettings().
parent::buildSettings($build, $items, $entity);
}
/**
* {@inheritdoc}
*/
public function preBuildElements(array &$build, $items, $entity, array $entities = []) {
parent::preBuildElements($build, $items, $entity, $entities);
$settings =& $build['settings'];
// Load the optionset to work with.
$optionset = Slick::loadWithFallback($settings['optionset']);
// Defines settings which should reach container and down to each item here.
$settings['nav'] = !empty($settings['optionset_thumbnail']) && isset($items[1]);
// Do not bother for SlickTextFormatter, or when vanilla is on.
if (empty($settings['vanilla'])) {
$lazy = $optionset
->getSetting('lazyLoad');
$settings['blazy'] = $lazy == 'blazy' || !empty($settings['blazy']);
$settings['lazy'] = $settings['blazy'] ? 'blazy' : $lazy;
if (empty($settings['blazy'])) {
$settings['lazy_class'] = $settings['lazy_attribute'] = 'lazy';
}
}
else {
// Nothing to work with Vanilla on, disable the asnavfor, else JS error.
$settings['nav'] = FALSE;
}
// Only trim overridables options if disabled.
if (empty($settings['override']) && isset($settings['overridables'])) {
$settings['overridables'] = array_filter($settings['overridables']);
}
$build['optionset'] = $optionset;
drupal_alter('slick_settings', $build, $items);
}
/**
* {@inheritdoc}
*/
public function getThumbnail(array $settings = [], $item = NULL) {
$thumbnail = [];
$uri = empty($settings['thumbnail_uri']) ? $settings['uri'] : $settings['thumbnail_uri'];
if (!empty($uri)) {
$thumbnail = [
'#theme' => 'image_style',
'#style_name' => $settings['thumbnail_style'] ?: 'thumbnail',
'#path' => $uri,
];
// Extract relevant variables from image or file entity/ media.
if ($item) {
foreach ([
'attributes',
'height',
'weight',
'alt',
'title',
] as $key) {
// Do not output empty value to prevent ugly title undefined.
if (isset($item->{$key})) {
$thumbnail["#{$key}"] = $item->{$key};
}
}
}
}
return $thumbnail;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlazyFormatter:: |
protected | property | The first image item found. | |
BlazyFormatter:: |
private | property | Checks if image dimensions are set. | |
BlazyFormatter:: |
public | function | ||
BlazyFormatter:: |
public | function | ||
BlazyFormatter:: |
protected | function | Sets dimensions once to reduce method calls, if image style contains crop. | |
BlazyManager:: |
public | function | Returns the entire contents using theme_field(), or theme_item_list(). | |
BlazyManager:: |
public | function | Build captions for both old image, or media entity. | |
BlazyManager:: |
private | function | Build out image, or anything related, including cache, CSS background, etc. | |
BlazyManager:: |
private | function | Build out (Responsive) image. | |
BlazyManager:: |
private | function | Build out Responsive image. | |
BlazyManager:: |
public | function |
Returns any config, or keyed by the $key. Overrides BlazyManagerBase:: |
|
BlazyManager:: |
protected | function | Build thumbnails, also to provide placeholder for blur effect. | |
BlazyManager:: |
public | function | Returns the enforced content, or image using theme_blazy(). | |
BlazyManager:: |
protected | function | Prepares Blazy outputs, extract items, and returns updated $settings. | |
BlazyManager:: |
protected | function | Prepares the Blazy image as a structured array ready for ::renderer(). | |
BlazyManager:: |
public | function | Builds the Blazy as a structured array ready for ::renderer(). | |
BlazyManager:: |
public | function | Builds the Blazy outputs as a structured array ready for ::renderer(). | |
BlazyManager:: |
private | function | Provides attachment and cache for both theme_field() and theme_item_list(). | |
BlazyManager:: |
protected | function | Build thumbnails, also to provide placeholder for blur effect. | |
BlazyManager:: |
public | function |
Typecast the needed settings, blazy-related module can override. Overrides BlazyManagerBase:: |
|
BlazyManagerBase:: |
private | property | Returns available styles with crop in the effect name. | |
BlazyManagerBase:: |
private | property | Checks if the image style contains crop in the effect name. | |
BlazyManagerBase:: |
protected | property | The blazy IO settings. | |
BlazyManagerBase:: |
protected | property | The available optionsets for all blazy-related modules. | |
BlazyManagerBase:: |
public | function |
Returns array of needed assets suitable for #attached property. Overrides BlazyManagerInterface:: |
|
BlazyManagerBase:: |
public | function | To be deprecated method. | |
BlazyManagerBase:: |
public | function | Collects defined skins as registered via hook_MODULE_NAME_skins_info(). | |
BlazyManagerBase:: |
public | function | To be deprecated method. | |
BlazyManagerBase:: |
public | function | Returns available image styles with crop in the name. | |
BlazyManagerBase:: |
public | function | Returns the cache id based on few generic setting values. | |
BlazyManagerBase:: |
public | function | Returns the common settings inherited down to each item. | |
BlazyManagerBase:: |
public | function | ||
BlazyManagerBase:: |
public | function | Returns drupalSettings for IO. | |
BlazyManagerBase:: |
public | function |
Gets the supported lightboxes. Overrides BlazyManagerInterface:: |
|
BlazyManagerBase:: |
public | function | Returns available optionsets for select options. | |
BlazyManagerBase:: |
public | function |
Checks for Blazy formatter such as from within a Views style plugin. Overrides BlazyManagerInterface:: |
|
BlazyManagerBase:: |
public | function | Checks if an image style contains crop effect. | |
SlickFormatter:: |
public | function |
Overrides BlazyFormatter:: |
|
SlickFormatter:: |
public | function |
Gets the thumbnail image using theme_image_style(). Overrides SlickFormatterInterface:: |
|
SlickFormatter:: |
public | function |
Overrides BlazyFormatter:: |