You are here

function ueditor_add_colorbox in UEditor - 百度编辑器 7.3

Same name and namespace in other branches
  1. 7.2 ueditor.module \ueditor_add_colorbox()

Add colorbox tag for ueditor image.

1 call to ueditor_add_colorbox()
ueditor_entity_view in ./ueditor.module
Implements hook_entity_view().

File

./ueditor.module, line 603
Integration ueditor for wysiwyg.

Code

function ueditor_add_colorbox($body, $settings) {
  if (!empty($settings['width'])) {
    $colorbox_width = $settings['width'];
  }
  if (!empty($settings['height'])) {
    $colorbox_height = $settings['height'];
  }
  $reg = '/<img\\s+src="([^"]+)"[^>]+>/';
  $replace = "<a href=\"\$1?width={$colorbox_width}&height={$colorbox_height}\" class=\"colorbox-load\" rel=\"ueditor-gallery\"><image src=\"\$1\" /></a>";
  $new_body = preg_replace($reg, $replace, $body);
  return $new_body;
}