You are here

public function JuiceboxFormatterInterface::buildEmbed in Juicebox HTML5 Responsive Image Galleries 8.2

Same name and namespace in other branches
  1. 8.3 src/JuiceboxFormatterInterface.php \Drupal\juicebox\JuiceboxFormatterInterface::buildEmbed()

Build a render array for the embed code of a Juicebox gallery.

Build once images and options have been added.

Note that this is different from Drupal\juicebox\JuiceboxGalleryInterface:renderEmbed() in that it handles ALL considerations for embedding. This includes the addition of the appropriate js and css which would otherwise need to be done independent of renderEmbed(). It also uses the Drupal theme system as opposed to just returning direct markup. Within Drupal this method should always be used.

Parameters

Drupal\juicebox\JuiceboxGalleryInterface $gallery: An fully populated Juicebox gallery object.

array $settings: An associative array of gallery-specific settings.

array $xml_route_info: Associative array of routing info that can be used to generate the URL to the XML. Includes:

  • route_name: The route name for the gallery XML.
  • route_parameters: Route parameters for the gallery XML.
  • options: An optional associative array of options that can be used by Drupal URL methods like Drupal\Core\Routing::generateFromRoute().

bool $add_js: Whether-or-not to add the Juicebox library and gallery-specific javascript.

bool $add_xml: It may be difficult or impossible to rebuild some types of formatters during a separate XML request, so this option offers a way around that by embedding the XML for the gallery directly into the HTML output. This XML can then be fetched from a request to this same page later via a sub-request. If TRUE xml-source-path and xml-source-id query strings are also added to the XML URL to help the XML building logic locate this XML data later. Setting this option may work around certain limitations but will likely lead to slower XML generation.

array $contextual: Optional contextual link information that may be used in the display. This array will be added as-is to the #contextual-links part of the render array that's used for the gallery's embed code.

Return value

array Drupal render array for the embed code that describes a gallery.

1 method overrides JuiceboxFormatterInterface::buildEmbed()
JuiceboxFormatter::buildEmbed in src/JuiceboxFormatter.php
Build a render array for the embed code of a Juicebox gallery.

File

src/JuiceboxFormatterInterface.php, line 141

Class

JuiceboxFormatterInterface
Interface definition for a Juicebox Formatter service.

Namespace

Drupal\juicebox

Code

public function buildEmbed(JuiceboxGalleryInterface $gallery, array $settings, array $xml_route_info, $add_js = TRUE, $add_xml = FALSE, array $contextual = []);