public function process(&$row, $published, $params) { $regex = "#{imatge\s*(.*?)}(.*?){/imatge}#s"; if (!$published) { $row->text = preg_replace($regex, '', $row->text); return true; } $matches = array(); preg_match_all($regex, $row->text, $matches, PREG_PATTERN_ORDER); if (!$matches) { return true; } $ePlugin = eFactory::getPlugin(); foreach ($matches[0] as $i => $match) { $attributes = $ePlugin->parseAttributes($matches[1][$i]); $this->alt_text= ''; if (isset($attributes['alt_text']) && ($attributes['alt_text'] != '')) { $this->alt_text= $attributes['alt_text']; } $this->caption= ''; if (isset($attributes['caption']) && ($attributes['caption'] != '')) { $this->caption= $attributes['caption']; } $this->float= ''; if (isset($attributes['float']) && ($attributes['float'] != '')) { $this->float= $attributes['float']; } /*$contents = $matches[1][$i];*/ if ($contents == '') { $html = '<div class="elx_warning">falta link imatge</div>'; } else { $html = '<div style="float:'.$this->float.';">'; $html = '<div><img alt="'.$this->alt_text.'" src="'.$contents.'" /></div><br />'; $html = '<p>'.$this->caption.'</p>'; $html = '</div>'; } $row->text = preg_replace("#".$match."#", $html, $row->text); } return true;}
OK guys, I will do it. Wait a few hours...
Ready and published Download Image plugin from EDC.It supports all the features you wanted, has a helper for easy input, integrated help, is mobile friendly and uses HTML5 tags figure and figcaption.Compatibility: Elxis 4.xCompatibility for the mobile version: Elxis 4.1+