/** * Attempt to create a resized image resized image * */ static function ResizedImage($attributes) { global $dataDir, $dirPrefix; //height and width from style $css_w = $css_h = false; if (!empty($attributes['style'])) { $css_args = explode(';', $attributes['style']); foreach ($css_args as $css_arg) { $css_arg = explode(':', $css_arg); if (count($css_arg) != 2) { continue; } $css_key = strtolower(trim($css_arg[0])); $css_value = strtolower(trim($css_arg[1])); $px_pos = strpos($css_value, 'px'); if (!$px_pos) { continue; } if ($css_key == 'width') { $css_w = substr($css_value, 0, $px_pos); } elseif ($css_key == 'height') { $css_h = substr($css_value, 0, $px_pos); } } } //width attribute if (!$css_w && isset($attributes['width']) && is_numeric($attributes['width'])) { $css_w = $attributes['width']; } //height attribute if (!$css_h && isset($attributes['height']) && is_numeric($attributes['height'])) { $css_h = $attributes['height']; } if (!$css_w && !$css_h) { return false; } //check src if (empty($attributes['src'])) { return false; } $src = urldecode($attributes['src']); $img_dir = $dirPrefix . '/data/_uploaded'; if ($src[0] != '/' && strpos($src, $img_dir) !== 0) { return false; } $src_relative = substr($src, strlen($img_dir)); return gp_edit::CreateImage($src_relative, $css_w, $css_h); }
/** * Get the content of the file in the trash so we can restore file information * - resized images * - special_galleries::UpdateGalleryInfo($title,$content) * */ function RestoreFile($title, $file, $title_info) { //get the file data $file_sections = array(); ob_start(); include $file; ob_get_clean(); // Restore resized images if (count($file_sections)) { includeFile('image.php'); gp_resized::SetIndex(); foreach ($file_sections as $section => $section_data) { if (!isset($section_data['resized_imgs'])) { continue; } foreach ($section_data['resized_imgs'] as $image_index => $sizes) { if (!isset(gp_resized::$index[$image_index])) { continue; } $img = gp_resized::$index[$image_index]; foreach ($sizes as $size) { list($width, $height) = explode('x', $size); gp_edit::CreateImage($img, $width, $height); } } gp_edit::ResizedImageUse(array(), $section_data['resized_imgs']); } gp_resized::SaveIndex(); } // Restore Galleries if (strpos($title_info['type'], 'gallery') !== false) { includeFile('special/special_galleries.php'); special_galleries::UpdateGalleryInfo($title, $file_sections); } }