Ejemplo n.º 1
0
 /**
  * Replace css resized images with resized copies of the original
  * ckeditor uses style height/width
  *
  */
 static function ResizeImages(&$html_content, &$img_list)
 {
     includeFile('tool/HTML_Output.php');
     includeFile('image.php');
     gp_resized::SetIndex();
     $orig_list = array();
     if (is_array($img_list)) {
         $orig_list = $img_list;
     }
     $img_list = array();
     //resize images
     $gp_html_output = new gp_html_output($html_content);
     foreach ($gp_html_output->dom_array as $key => $node) {
         if (!is_array($node) || !array_key_exists('tag', $node)) {
             continue;
         }
         $tag = $node['tag'];
         if ($tag != 'img' || !isset($node['attributes']['src'])) {
             continue;
         }
         $original_src = $node['attributes']['src'];
         $resized_data = gp_edit::ResizedImage($node['attributes']);
         if ($resized_data !== false) {
             $img = $resized_data['img'];
             $index = $resized_data['index'];
             $resized_src = common::GetDir('/include/image.php', true) . '?i=' . $index . '&w=' . $resized_data['w'] . '&h=' . $resized_data['h'] . '&img=' . rawurlencode($img);
             $gp_html_output->dom_array[$key]['attributes']['src'] = $resized_src;
             $img_list[$index][] = $resized_data['w'] . 'x' . $resized_data['h'];
             $img_list[$index] = array_unique($img_list[$index]);
             gp_resized::$index[$index] = $img;
         }
     }
     $gp_html_output->Rebuild();
     $html_content = $gp_html_output->result;
     gp_edit::ResizedImageUse($orig_list, $img_list);
     gp_resized::SaveIndex();
 }