Exemple #1
0
 protected function onShortcode($content, $code, \Drone\HTML &$html)
 {
     // ID
     $int_id = (int) $this->getID();
     // Retina
     if ($int_id && $this->so('width') && ($size = Func::wpGetImageSizeName($content)) !== false) {
         $content = str_replace('<img ', '<img ' . trim(\Everything::getAttachmentImages($int_id, $size, 'html') . ' '), $content);
     }
     // Class
     $class = preg_match('/class="([^"]*)"/i', $content, $m) ? preg_replace('/\\balign(none|left|right|center)\\b/i', '', $m[1]) : '';
     // Content
     $content = preg_replace('/class="([^"]*)"/i', '', trim($content));
     // Images attributes
     $atts = array();
     if (preg_match_all('/\\b(border|hover|fancybox)-([a-z]+)\\b/i', $class, $matches, PREG_SET_ORDER) > 0) {
         foreach ($matches as $match) {
             $atts[$match[1]] = str_ireplace('none', '', $match[2]);
             $class = str_replace($match[0], '', $class);
         }
     }
     // Settings
     if (strpos($content, '<a ') === 0) {
         $content = str_replace('<a ', sprintf('<a %s data-fancybox-group="post-%d" data-fancybox-title="%s" ', \Everything::getImageAttrs('a', $atts, 'html'), get_the_ID(), esc_attr($this->so('caption'))), $content);
     } else {
         $content = sprintf('<div %s>%s</div>', \Everything::getImageAttrs('div', $atts, 'html'), $content);
     }
     // Figure
     $html = HTML::figure()->id($this->so('id') ? $this->so('id') : null)->addClass($class, $this->so('align'), $this->so('align') == 'alignleft' || $this->so('align') == 'alignright' ? 'fixed' : null)->style($this->so('width') ? "width: {$this->so('width')}px;" : null)->add($content);
     // Caption
     if ($this->so('caption')) {
         $html->addNew('figcaption')->add($this->so('caption'));
     }
 }