Example #1
0
function flagCreateNewThumb()
{
    global $wpdb;
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct FlAG capability
    if (!current_user_can('FlAG Manage gallery')) {
        die('-1');
    }
    require_once dirname(dirname(__FILE__)) . '/flag-config.php';
    include_once flagGallery::graphic_library();
    $flag_options = get_option('flag_options');
    $id = (int) $_POST['id'];
    $picture = flagdb::find_image($id);
    $x = round($_POST['x'] * $_POST['rr'], 0);
    $y = round($_POST['y'] * $_POST['rr'], 0);
    $w = round($_POST['w'] * $_POST['rr'], 0);
    $h = round($_POST['h'] * $_POST['rr'], 0);
    $thumb = new flag_Thumbnail($picture->imagePath, true);
    $thumb->crop($x, $y, $w, $h);
    if ($flag_options['thumbFix']) {
        if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
            $thumb->resize($flag_options['thumbWidth'], 0);
        } else {
            $thumb->resize(0, $flag_options['thumbHeight']);
        }
    } else {
        $thumb->resize($flag_options['thumbWidth'], $flag_options['thumbHeight']);
    }
    if ($thumb->save($picture->thumbPath, 100)) {
        //read the new sizes
        $new_size = @getimagesize($picture->thumbPath);
        $size['width'] = $new_size[0];
        $size['height'] = $new_size[1];
        // add them to the database
        flagdb::update_image_meta($picture->pid, array('thumbnail' => $size));
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    exit;
}
Example #2
0
 /**
  * flagAdmin::resize_image() - create a new image, based on the height /width
  * 
  * @class flagAdmin
  * @param object | int $image contain all information about the image or the id
  * @param integer $width optional 
  * @param integer $height optional
  * @return string result code
  */
 static function resize_image($image, $width = 0, $height = 0)
 {
     global $flag;
     if (!class_exists('flag_Thumbnail')) {
         require_once flagGallery::graphic_library();
     }
     if (is_numeric($image)) {
         $image = flagdb::find_image($image);
     }
     if (!is_object($image)) {
         return __('Object didn\'t contain correct data', 'flag');
     }
     // before we start we import the meta data to database (required for uploads before V0.40)
     flagAdmin::maybe_import_meta($image->pid);
     // if no parameter is set, take global settings
     $width = $width == 0 ? $flag->options['imgWidth'] : $width;
     $height = $height == 0 ? $flag->options['imgHeight'] : $height;
     if (!is_writable($image->imagePath)) {
         return ' <strong>' . $image->filename . __(' is not writeable', 'flag') . '</strong>';
     }
     $file = new flag_Thumbnail($image->imagePath, TRUE);
     // skip if file is not there
     if (!$file->error) {
         $file->resize($width, $height, 4);
         $file->save($image->imagePath, $flag->options['imgQuality']);
         // read the new sizes
         $size = @getimagesize($image->imagePath);
         // add them to the database
         flagdb::update_image_meta($image->pid, array('width' => $size[0], 'height' => $size[1]));
         $file->destruct();
     } else {
         $file->destruct();
         return ' <strong>' . $image->filename . ' (Error : ' . $file->errmsg . ')</strong>';
     }
     return '1';
 }
Example #3
0
**/
require_once dirname(dirname(__FILE__)) . '/flag-config.php';
require_once FLAG_ABSPATH . '/lib/image.php';
if (!is_user_logged_in()) {
    die(__('Cheatin&#8217; uh?'));
}
if (!current_user_can('FlAG Manage gallery')) {
    die(__('Cheatin&#8217; uh?'));
}
global $wpdb;
$id = (int) $_GET['id'];
// let's get the image data
$picture = flagdb::find_image($id);
include_once flagGallery::graphic_library();
$flag_options = get_option('flag_options');
$thumb = new flag_Thumbnail($picture->imagePath, TRUE);
$thumb->resize(350, 350);
// we need the new dimension
$resizedPreviewInfo = $thumb->newDimensions;
$thumb->destruct();
$preview_image = FLAG_URLPATH . 'flagshow.php?pid=' . $picture->pid . '&amp;width=350&amp;height=350';
$imageInfo = @getimagesize($picture->imagePath);
$rr = round($imageInfo[0] / $resizedPreviewInfo['newWidth'], 2);
$WidthHtmlPrev = $flag_options['thumbWidth'];
$HeightHtmlPrev = $flag_options['thumbHeight'];
if ($flag_options['thumbFix'] == 1) {
    $WidthHtmlPrev = $flag_options['thumbWidth'];
    $HeightHtmlPrev = $flag_options['thumbHeight'];
} else {
    // H > W
    if ($imageInfo[1] > $imageInfo[0]) {
Example #4
0
// Load wp-config
if (!defined('ABSPATH')) {
    require_once dirname(__FILE__) . '/flag-config.php';
}
// reference thumbnail class
include_once flagGallery::graphic_library();
include_once 'lib/core.php';
// get the plugin options
$flag_options = get_option('flag_options');
// Some parameters from the URL
if (!isset($_GET['pid'])) {
    exit;
}
$pictureID = intval($_GET['pid']);
if (!$pictureID) {
    exit;
}
// let's get the image data
$picture = flagdb::find_image($pictureID);
if (!is_object($picture)) {
    exit;
}
$thumb = new flag_Thumbnail($picture->imagePath);
// Resize if necessary
if (!empty($_GET['width']) || !empty($_GET['height'])) {
    $thumb->resize(intval($_GET['width']), intval($_GET['height']));
}
// Show thumbnail
$thumb->show();
$thumb->destruct();
exit;