public static function postMarkdownHook($original, $data) { $text = trim($data->text); // Process galleries foreach (self::$baguettes['galleries'] as $key => $value) { $images = self::processTagContent($value['content']); $parameters = self::processParameters($value['parameters']); // Set parameters $layout = !isset($parameters['layout']) ? Baguette::$defaultLayout : $parameters['layout']; $class = !isset($parameters['class']) ? Baguette::$defaultClass : $parameters['class']; // Insert image if (count($images) > 0) { $text = str_replace($key, Baguette::makeBaguetteGallery($images, $layout, $class), $text); } else { $text = str_replace($key, $value['original'], $text); } } // Process singles foreach (self::$baguettes['singles'] as $key => $value) { $image = self::processTagContent($value['content']); $parameters = self::processParameters($value['parameters']); // Set parameters $class = !isset($parameters['class']) ? Baguette::$defaultClass : $parameters['class']; // Insert image if (count($image) > 0) { $text = str_replace($key, Baguette::makeBaguette($image[0]['path'], $image[0]['caption'], $class), $text); } else { $text = str_replace($key, $value['original'], $text); } } $data->text = $text; }
public function getImageMarkup() { $html = ""; // Create anchor that opens baguette if ($this->type == 'file') { $html .= '<a href="' . $this->path . '" ' . Baguette::getResponsiveAttributes($this->image) . ' data-caption="' . $this->caption . '" target="_blank">'; } else { $html .= '<a href="' . $this->path . '" data-caption="' . $this->caption . '" target="_blank">'; } // Make a responsive element if we have a System\Models\File $html .= $this->thumbType == 'file' ? $this->getResponsiveMarkup() : '<img src="' . $this->thumbPath . '" alt="' . $this->caption . '">'; // Return the html return $html . '</a>'; }
public function defineProperties() { return ['captions' => ['title' => 'Captions', 'description' => 'Display image captions', 'default' => true, 'type' => 'checkbox'], 'buttons' => ['title' => 'Buttons', 'description' => 'Display buttons', 'default' => true, 'type' => 'checkbox'], 'async' => ['title' => 'Async', 'description' => 'Load files asynchronously', 'default' => true, 'type' => 'checkbox'], 'preload' => ['title' => 'Preload', 'description' => 'How many files should be preloaded from current image', 'default' => 2, 'type' => 'string', 'placeholder' => '2', 'validationPattern' => '^[0-9]+$', 'validationMessage' => 'The preload property can contain only numeric symbols'], 'animation' => ['title' => 'Animation', 'description' => 'Animation type', 'default' => 'slideIn', 'type' => 'dropdown', 'options' => [false => 'none', 'slideIn' => 'Slide in', 'fadeIn' => 'Fade in']], 'initialize' => ['title' => 'Initialize', 'description' => 'Can be set to false to prevent the gallery from being initialized automatically', 'default' => true, 'type' => 'checkbox'], 'includeAssets' => ['title' => 'Include Assets', 'description' => 'Can be set to false to prevent the gallery from including it\'s shipped version of baguetteBox', 'default' => true, 'type' => 'checkbox'], 'class' => ['title' => 'Gallery Class', 'description' => 'To use separate configuration of multiple gallery instances, they must each have their own class', 'default' => Baguette::$defaultClass, 'type' => 'string', 'placeholder' => Baguette::$defaultClass], 'layout' => ['title' => 'Layout Template', 'description' => 'The name of the gallery layout to use', 'default' => Baguette::$defaultLayout, 'type' => 'dropdown', 'options' => Baguette::getLayouts()]]; }