public function MasonryService::getMasonryDefaultOptions in Masonry API 8
Get default Masonry options.
Return value
array An associative array of default options for Masonry. Contains:
- layoutColumnWidth: The width of each column (in pixels or as a percentage).
- layoutColumnWidthUnit: The units to use for the column width ('px' or '%').
- gutterWidth: The spacing between each column (in pixels).
- isLayoutResizable: Automatically rearrange items when the container is resized.
- isLayoutAnimated: Animate item rearrangements.
- layoutAnimationDuration: The duration of animations (in milliseconds).
- isLayoutFitsWidth: Sets the width of the container to the nearest column. Ideal for centering Masonry layouts.
- isLayoutRtlMode: Display items from right-to-left.
- isLayoutImagesLoadedFirst: Load all images first before triggering Masonry.
- isLayoutImagesLazyLoaded: Custom observer to support layout rebuild in lazysizes images lazy loading.
- imageLazyloadSelector: lazyLoad class selector used by lazysizes.
- imageLazyloadedSelector: lazyLoaded class selector used by lazysizes.
- stampSelector: Specifies which elements are stamped within the layout using css selector.
- isItemsPositionInPercent: Sets item positions in percent values, rather than pixel values.
2 calls to MasonryService::getMasonryDefaultOptions()
- MasonryService::applyMasonryDisplay in src/
Services/ MasonryService.php - Apply Masonry to a container.
- MasonryService::buildSettingsForm in src/
Services/ MasonryService.php - Build the masonry setting configuration form.
File
- src/
Services/ MasonryService.php, line 102 - Masonry service file.
Class
- MasonryService
- Wrapper methods for Masonry API methods.
Namespace
Drupal\masonry\ServicesCode
public function getMasonryDefaultOptions() {
$options = [
'layoutColumnWidth' => '',
'layoutColumnWidthUnit' => 'px',
'gutterWidth' => '0',
'isLayoutResizable' => TRUE,
'isLayoutAnimated' => TRUE,
'layoutAnimationDuration' => '500',
'isLayoutFitsWidth' => FALSE,
'isLayoutRtlMode' => $this->languageManager
->getCurrentLanguage()
->getDirection() == LanguageInterface::DIRECTION_RTL,
'isLayoutImagesLoadedFirst' => TRUE,
'isLayoutImagesLazyLoaded' => FALSE,
'imageLazyloadSelector' => 'lazyload',
'imageLazyloadedSelector' => 'lazyloaded',
'stampSelector' => '',
'isItemsPositionInPercent' => FALSE,
'extraOptions' => [],
];
// Loazyloading classes are auto-calculated for user simplicity. When
// lazysizes is used without a Drupal module, this means DX is able to use
// hook_masonry_default_options_alter or hook_masonry_options_form_alter to
// override this setting.
if ($this->moduleHandler
->moduleExists('lazy')) {
$config = $this->configFactory
->get('lazy.settings');
$options['imageLazyloadSelector'] = $config
->get('lazysizes.lazyClass');
$options['imageLazyloadedSelector'] = $config
->get('lazysizes.loadedClass');
}
return $options;
}