本文整理汇总了PHP中nggdb::update_image_meta方法的典型用法代码示例。如果您正苦于以下问题:PHP nggdb::update_image_meta方法的具体用法?PHP nggdb::update_image_meta怎么用?PHP nggdb::update_image_meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggdb
的用法示例。
在下文中一共展示了nggdb::update_image_meta方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ewww_added_new_image
function ewww_added_new_image($image, $storage = null)
{
ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
global $ewww_defer;
if (empty($storage)) {
// creating the 'registry' object for working with nextgen
$registry = C_Component_Registry::get_instance();
// creating a database storage object from the 'registry' object
$storage = $registry->get_utility('I_Gallery_Storage');
}
// find the image id
if (is_array($image)) {
$image_id = $image['id'];
$image = $storage->object->_image_mapper->find($image_id, TRUE);
} else {
$image_id = $storage->object->_get_image_id($image);
}
ewwwio_debug_message("image id: {$image_id}");
if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) {
ewww_image_optimizer_add_deferred_attachment("nextgen2,{$image_id}");
return;
}
// get an array of sizes available for the $image
$sizes = $storage->get_image_sizes();
// run the optimizer on the image for each $size
foreach ($sizes as $size) {
if ($size === 'full') {
$full_size = true;
} else {
$full_size = false;
}
// get the absolute path
$file_path = $storage->get_image_abspath($image, $size);
ewwwio_debug_message("optimizing (nextgen): {$file_path}");
// optimize the image and grab the results
$res = ewww_image_optimizer($file_path, 2, false, false, $full_size);
ewwwio_debug_message("results {$res[1]}");
// only if we're dealing with the full-size original
if ($size === 'full') {
// update the metadata for the optimized image
$image->meta_data['ewww_image_optimizer'] = $res[1];
} else {
$image->meta_data[$size]['ewww_image_optimizer'] = $res[1];
}
nggdb::update_image_meta($image_id, $image->meta_data);
ewwwio_debug_message('storing results for full size image');
}
return $image;
}
示例2: ewww_added_new_image
function ewww_added_new_image($image, $storage = null)
{
global $ewww_debug;
$ewww_debug .= "<b>ewww_added_new_image()</b><br>";
if (empty($storage)) {
// creating the 'registry' object for working with nextgen
$registry = C_Component_Registry::get_instance();
// creating a database storage object from the 'registry' object
$storage = $registry->get_utility('I_Gallery_Storage');
}
// find the image id
$image_id = $storage->object->_get_image_id($image);
$ewww_debug .= "image id: {$image_id}<br>";
// get an array of sizes available for the $image
$sizes = $storage->get_image_sizes();
// run the optimizer on the image for each $size
foreach ($sizes as $size) {
if ($size === 'full') {
$full_size = true;
} else {
$full_size = false;
}
// get the absolute path
$file_path = $storage->get_image_abspath($image, $size);
$ewww_debug .= "optimizing (nextgen): {$file_path}<br>";
// optimize the image and grab the results
$res = ewww_image_optimizer($file_path, 2, false, false, $full_size);
$ewww_debug .= "results " . $res[1] . "<br>";
// only if we're dealing with the full-size original
if ($size === 'full') {
// update the metadata for the optimized image
$image->meta_data['ewww_image_optimizer'] = $res[1];
} else {
$image->meta_data[$size]['ewww_image_optimizer'] = $res[1];
}
nggdb::update_image_meta($image_id, $image->meta_data);
$ewww_debug .= 'storing results for full size image<br>';
}
ewww_image_optimizer_debug_log();
return $image;
}
示例3: ewww_ngg_bulk_loop
function ewww_ngg_bulk_loop()
{
if (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can('edit_others_posts')) {
wp_die(__('Access token has expired, please reload the page.', EWWW_IMAGE_OPTIMIZER_DOMAIN));
}
// need this file to work with metadata
ewww_image_optimizer_require(WP_CONTENT_DIR . '/plugins/nextgen-gallery/lib/meta.php');
// find out what time we started, in microseconds
$started = microtime(true);
$id = $_POST['ewww_attachment'];
// get the metadata
$meta = new nggMeta($id);
// retrieve the filepath
$file_path = $meta->image->imagePath;
// run the optimizer on the current image
$fres = ewww_image_optimizer($file_path, 2, false, false, true);
global $ewww_exceed;
if (!empty($ewww_exceed)) {
echo '-9exceeded';
die;
}
// update the metadata of the optimized image
nggdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
// output the results of the optimization
printf("<p>" . __('Optimized image:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <strong>%s</strong><br>", $meta->image->filename);
printf(__('Full size - %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $fres[1]);
// get the filepath of the thumbnail image
$thumb_path = $meta->image->thumbPath;
// run the optimization on the thumbnail
$tres = ewww_image_optimizer($thumb_path, 2, false, true);
// output the results of the thumb optimization
printf(__('Thumbnail - %s', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "<br>", $tres[1]);
// outupt how much time we spent
$elapsed = microtime(true) - $started;
printf(__('Elapsed: %.3f seconds', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</p>", $elapsed);
// get the list of attachments remaining from the db
$attachments = get_option('ewww_image_optimizer_bulk_ngg_attachments');
// remove the first item
if (!empty($attachments)) {
array_shift($attachments);
}
// and store the list back in the db
update_option('ewww_image_optimizer_bulk_ngg_attachments', $attachments);
die;
}
示例4: generate_image_size
/**
* Overrides the NextGen Gallery function, to smush the dynamic images and thumbnails created by gallery
*
* @param C_Image|int|stdClass $image
* @param $size
* @param null $params
* @param bool|false $skip_defaults
*
* @return bool|object
*/
function generate_image_size($image, $size, $params = null, $skip_defaults = false)
{
global $WpSmush;
$image_id = !empty($image->pid) ? $image->pid : '';
//Get image from storage object if we don't have it already
if (empty($image_id)) {
//Get metadata For the image
// Registry Object for NextGen Gallery
$registry = C_Component_Registry::get_instance();
//Gallery Storage Object
$storage = $registry->get_utility('I_Gallery_Storage');
$image_id = $storage->object->_get_image_id($image);
}
//Call the actual function to generate the image, and pass the image to smush
$success = $this->call_parent('generate_image_size', $image, $size, $params, $skip_defaults);
if ($success) {
$filename = $success->fileName;
//Smush it, if it exists
if (file_exists($filename)) {
$response = $WpSmush->do_smushit($filename, $image_id, 'nextgen');
//If the image was smushed
if (!is_wp_error($response) && !empty($response['data']) && $response['data']->bytes_saved > 0) {
//Check for existing stats
if (!empty($image->meta_data) && !empty($image->meta_data['wp_smush'])) {
$stats = $image->meta_data['wp_smush'];
} else {
//Initialize stats array
$stats = array("stats" => array_merge($WpSmush->_get_size_signature(), array('api_version' => -1, 'lossy' => -1, 'keep_exif' => false)), 'sizes' => array());
$stats['bytes'] = $response['data']->bytes_saved;
$stats['percent'] = $response['data']->compression;
$stats['size_after'] = $response['data']->after_size;
$stats['size_before'] = $response['data']->before_size;
$stats['time'] = $response['data']->time;
}
$stats['sizes'][$size] = (object) $WpSmush->_array_fill_placeholders($WpSmush->_get_size_signature(), (array) $response['data']);
if (isset($image->metadata)) {
$image->meta_data['wp_smush'] = $stats;
nggdb::update_image_meta($image->pid, $image->meta_data);
}
//Allows To get the stats for each image, after the image is smushed
do_action('wp_smush_nextgen_image_stats', $image_id, $stats);
}
}
}
return $success;
}
示例5: ewww_image_optimizer_bulk_next
function ewww_image_optimizer_bulk_next($delay, $attachments)
{
// toggle the resume flag to indicate an operation is in progress
update_option('ewww_image_optimizer_bulk_ngg_resume', 'true');
// need this file to work with metadata
require_once WP_CONTENT_DIR . '/plugins/nextcellent-gallery-nextgen-legacy/lib/meta.php';
foreach ($attachments as $id) {
sleep($delay);
// find out what time we started, in microseconds
$started = microtime(true);
// get the metadata
$meta = new nggMeta($id);
// retrieve the filepath
$file_path = $meta->image->imagePath;
// run the optimizer on the current image
$fres = ewww_image_optimizer($file_path, 2, false, false, true);
// update the metadata of the optimized image
nggdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
// output the results of the optimization
WP_CLI::line(__('Optimized image:', EWWW_IMAGE_OPTIMIZER_DOMAIN) . $meta->image->filename);
WP_CLI::line(sprintf(__('Full size - %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), html_entity_decode($fres[1])));
// get the filepath of the thumbnail image
$thumb_path = $meta->image->thumbPath;
// run the optimization on the thumbnail
$tres = ewww_image_optimizer($thumb_path, 2, false, true);
// output the results of the thumb optimization
WP_CLI::line(sprintf(__('Thumbnail - %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), html_entity_decode($tres[1])));
// outupt how much time we spent
$elapsed = microtime(true) - $started;
WP_CLI::line(sprintf(__('Elapsed: %.3f seconds', EWWW_IMAGE_OPTIMIZER_DOMAIN), $elapsed));
// get the list of attachments remaining from the db
$attachments = get_option('ewww_image_optimizer_bulk_ngg_attachments');
// remove the first item
if (!empty($attachments)) {
array_shift($attachments);
}
// and store the list back in the db
update_option('ewww_image_optimizer_bulk_ngg_attachments', $attachments, false);
}
// reset all the bulk options in the db
update_option('ewww_image_optimizer_bulk_ngg_resume', '');
update_option('ewww_image_optimizer_bulk_ngg_attachments', '', false);
// and let the user know we are done
WP_CLI::success(__('Finished Optimization!', EWWW_IMAGE_OPTIMIZER_DOMAIN));
}
示例6: copy_images
/**
* Copy images to another gallery
*
* @class nggAdmin
* @param array|int $pic_ids ID's of the images
* @param int $dest_gid destination gallery
* @return void
*/
function copy_images($pic_ids, $dest_gid)
{
require_once NGGALLERY_ABSPATH . '/lib/meta.php';
$errors = $messages = '';
if (!is_array($pic_ids)) {
$pic_ids = array($pic_ids);
}
// Get destination gallery
$destination = nggdb::find_gallery($dest_gid);
if ($destination == null) {
nggGallery::show_error(__('The destination gallery does not exist', 'nggallery'));
return;
}
// Check for folder permission
if (!is_writeable(WINABSPATH . $destination->path)) {
$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $destination->path);
nggGallery::show_error($message);
return;
}
// Get pictures
$images = nggdb::find_images_in_list($pic_ids);
$destination_path = WINABSPATH . $destination->path;
foreach ($images as $image) {
// WPMU action
if (nggWPMU::check_quota()) {
return;
}
$i = 0;
$tmp_prefix = '';
$destination_file_name = $image->filename;
while (file_exists($destination_path . '/' . $destination_file_name)) {
$tmp_prefix = 'copy_' . $i++ . '_';
$destination_file_name = $tmp_prefix . $image->filename;
}
$destination_file_path = $destination_path . '/' . $destination_file_name;
$destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name;
// Copy files
if (!@copy($image->imagePath, $destination_file_path)) {
$errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'nggallery'), $image->filename, $destination_file_path) . '<br />';
continue;
}
// Copy backup file, if possible
@copy($image->imagePath . '_backup', $destination_file_path . '_backup');
// Copy the thumbnail if possible
@copy($image->thumbPath, $destination_thumb_file_path);
// Create new database entry for the image
$new_pid = nggdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude);
if (!isset($new_pid)) {
$errors .= sprintf(__('Failed to copy database row for picture %s', 'nggallery'), $image->pid) . '<br />';
continue;
}
// Copy tags
nggTags::copy_tags($image->pid, $new_pid);
// Copy meta information
$meta = new nggMeta($image->pid);
nggdb::update_image_meta($new_pid, $meta->image->meta_data);
if ($tmp_prefix != '') {
$messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) » The file already existed in the destination gallery.', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
} else {
$messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
}
}
// Finish by showing errors or success
if ($errors == '') {
$link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>';
$messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .', 'nggallery'), count($images), $link);
}
if ($messages != '') {
nggGallery::show_message($messages);
}
if ($errors != '') {
nggGallery::show_error($errors);
}
return;
}
示例7: maybe_import_meta
/**
* Maybe import some meta data to the database. The functions checks the flag 'saved'
* and if based on compat reason (pre V1.4.0) we save then some meta datas to the database
*
* @since V1.4.0
* @param int $id
* @return result
*/
function maybe_import_meta($image_or_id)
{
require_once NGGALLERY_ABSPATH . '/lib/meta.php';
$id = is_int($image_or_id) ? $image_or_id : $image_or_id->{$image_or_id->id_field};
$meta_obj = new nggMeta($image_or_id);
if ($meta_obj->image->meta_data['saved'] != true) {
$common = $meta_obj->get_common_meta();
//this flag will inform us that the import is already one time performed
$common['saved'] = true;
$result = nggdb::update_image_meta($id, $common);
} else {
return false;
}
return $result;
}
示例8: createNewThumb
function createNewThumb()
{
global $ngg;
// check for correct capability
if (!is_user_logged_in()) {
die('-1');
}
// check for correct NextGEN capability
if (!current_user_can('NextGEN Manage gallery')) {
die('-1');
}
include_once nggGallery::graphic_library();
$id = (int) $_POST['id'];
$picture = nggdb::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 ngg_Thumbnail($picture->imagePath, TRUE);
$thumb->crop($x, $y, $w, $h);
// Note : the routine is a bit different to create_thumbnail(), due to rounding it's resized in the other way
if ($ngg->options['thumbfix']) {
// check for portrait format
if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
// first resize to the wanted height, here changed to create_thumbnail()
$thumb->resize(0, $ngg->options['thumbheight']);
// get optimal y startpos
$ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
$thumb->crop(0, $ypos, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
} else {
// first resize to the wanted width, here changed to create_thumbnail()
$thumb->resize($ngg->options['thumbwidth'], 0);
//
// get optimal x startpos
$xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
$thumb->crop($xpos, 0, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
}
//this create a thumbnail but keep ratio settings
} else {
$thumb->resize($ngg->options['thumbwidth'], $ngg->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
nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
echo "OK";
} else {
header('HTTP/1.1 500 Internal Server Error');
echo "KO";
}
exit;
}
示例9: ewww_ngg_optimize
function ewww_ngg_optimize($id)
{
// retrieve the metadata for the image
$meta = new nggMeta($id);
// retrieve the image path
$file_path = $meta->image->imagePath;
// run the optimizer on the current image
$fres = ewww_image_optimizer($file_path, 2, false, false, true);
// update the metadata for the optimized image
nggdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
// get the filepath of the thumbnail image
$thumb_path = $meta->image->thumbPath;
// run the optimization on the thumbnail
$tres = ewww_image_optimizer($thumb_path, 2, false, true);
return array($fres, $tres);
}
示例10: ewww_image_optimizer_import_loop
//.........这里部分代码省略.........
$record = array();
$gallery_path = '';
foreach ($galleries as $gallery) {
if ($gallery[0] == $image[3]) {
$gallery_path = trailingslashit($gallery[1]);
}
}
$meta = unserialize($image[1]);
// get an array of sizes available for the $image
foreach ($sizes as $size) {
// get the absolute path
if ($size === 'full' || $size === 'original' || $size === 'image') {
if (!empty($meta['ewww_image_optimizer'])) {
$file_path = ABSPATH . $gallery_path . $image[2];
$ewww_debug .= "nextgen path generated: {$file_path}<br>";
$record = ewww_image_optimizer_import_file($file_path, $meta['ewww_image_optimizer'], $already_optimized);
}
} elseif (!empty($meta[$size]['ewww_image_optimizer'])) {
if (isset($meta[$size]['filename'])) {
$file_path = ABSPATH . $gallery_path . trailingslashit('thumbs') . $meta[$size]['filename'];
} else {
$file_path = ABSPATH . $gallery_path . trailingslashit('thumbs') . 'thumbs_' . $image[2];
}
$ewww_debug .= "nextgen path generated: {$file_path}<br>";
$record = ewww_image_optimizer_import_file($file_path, $meta[$size]['ewww_image_optimizer'], $already_optimized);
} elseif (!empty($meta['ewww_image_optimizer'])) {
if (isset($meta[$size]['filename'])) {
$file_path = ABSPATH . $gallery_path . trailingslashit('thumbs') . $meta[$size]['filename'];
} else {
$file_path = ABSPATH . $gallery_path . trailingslashit('thumbs') . 'thumbs_' . $image[2];
}
$ewww_debug .= "nextgen path generated: {$file_path}<br>";
$meta[$size]['ewww_image_optimizer'] = __('Unknown Savings', EWWW_IMAGE_OPTIMIZER_DOMAIN);
nggdb::update_image_meta($image[0], $meta);
$record = ewww_image_optimizer_import_file($file_path, $meta[$size]['ewww_image_optimizer'], $already_optimized);
}
if (!empty($record)) {
$rows[] = "('{$record['0']}', '{$record['1']}', '{$record['2']}', '{$record['3']}', true)";
}
}
ewww_image_optimizer_debug_log();
}
$import_count += $import_status['nextgen'];
}
// fla gallery import
if ($import_finished && isset($import_status['flag'])) {
$import_finished = false;
$images = $wpdb->get_results("SELECT pid,meta_data,filename,galleryid FROM {$wpdb->flagpictures} WHERE meta_data LIKE '%ewww_image_optimizer%' LIMIT {$import_status['flag']}, 100", ARRAY_N);
$galleries = $wpdb->get_results("SELECT gid,path FROM {$wpdb->flaggallery}", ARRAY_N);
if (count($images) === 0) {
$import_finished = true;
} else {
$import_status['flag'] += count($images);
}
// need this file to work with flag meta
foreach ($images as $image) {
$record = array();
$gallery_path = '';
foreach ($galleries as $gallery) {
if ($gallery[0] == $image[3]) {
$gallery_path = trailingslashit($gallery[1]);
}
}
// get the image meta for the current ID
$meta = unserialize($image[1]);
$file_path = ABSPATH . $gallery_path . $image[2];
示例11: ewww_added_new_image_slow
function ewww_added_new_image_slow($image)
{
// query the filesystem path of the gallery from the database
global $ewww_defer;
global $wpdb;
$q = $wpdb->prepare("SELECT path FROM {$wpdb->prefix}ngg_gallery WHERE gid = %d LIMIT 1", $image['galleryID']);
$gallery_path = $wpdb->get_var($q);
// if we have a path to work with
if ($gallery_path) {
// construct the absolute path of the current image
$file_path = trailingslashit($gallery_path) . $image['filename'];
if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) {
ewww_image_optimizer_add_deferred_attachment("nextcellent,{$image['id']}");
return;
}
// run the optimizer on the current image
$res = ewww_image_optimizer(ABSPATH . $file_path, 2, false, false, true);
// update the metadata for the optimized image
nggdb::update_image_meta($image['id'], array('ewww_image_optimizer' => $res[1]));
}
}
示例12: createNewThumb
function createNewThumb()
{
// check for correct capability
if (!is_user_logged_in()) {
die('-1');
}
// check for correct NextGEN capability
if (!current_user_can('NextGEN Manage gallery')) {
die('-1');
}
require_once dirname(dirname(__FILE__)) . '/ngg-config.php';
include_once nggGallery::graphic_library();
$ngg_options = get_option('ngg_options');
$id = (int) $_POST['id'];
$picture = nggdb::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 ngg_Thumbnail($picture->imagePath, TRUE);
$thumb->crop($x, $y, $w, $h);
if ($ngg_options['thumbfix']) {
if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
$thumb->resize($ngg_options['thumbwidth'], 0);
} else {
$thumb->resize(0, $ngg_options['thumbheight']);
}
} else {
$thumb->resize($ngg_options['thumbwidth'], $ngg_options['thumbheight'], $ngg_options['thumbResampleMode']);
}
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
nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
echo "OK";
} else {
header('HTTP/1.1 500 Internal Server Error');
echo "KO";
}
exit;
}
示例13: ewww_ngg_bulk_loop
function ewww_ngg_bulk_loop()
{
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can('edit_others_posts')) {
wp_die(__('Cheatin’ eh?'));
}
// need this file to work with metadata
require_once WP_CONTENT_DIR . '/plugins/nextgen-gallery/lib/meta.php';
// find out what time we started, in microseconds
$started = microtime(true);
$id = $_POST['attachment'];
// get the metadata
$meta = new nggMeta($id);
// retrieve the filepath
$file_path = $meta->image->imagePath;
// run the optimizer on the current image
$fres = ewww_image_optimizer($file_path, 2, false, false);
// update the metadata of the optimized image
nggdb::update_image_meta($id, array('ewww_image_optimizer' => $fres[1]));
// output the results of the optimization
printf("<p>Optimized image: <strong>%s</strong><br>", $meta->image->filename);
printf("Full size - %s<br>", $fres[1]);
// get the filepath of the thumbnail image
$thumb_path = $meta->image->thumbPath;
// run the optimization on the thumbnail
$tres = ewww_image_optimizer($thumb_path, 2, false, true);
// output the results of the thumb optimization
printf("Thumbnail - %s<br>", $tres[1]);
// outupt how much time we spent
$elapsed = microtime(true) - $started;
echo "Elapsed: " . round($elapsed, 3) . " seconds</p>";
// get the list of attachments remaining from the db
$attachments = get_option('ewww_image_optimizer_bulk_ngg_attachments');
// remove the first item
array_shift($attachments);
// and store the list back in the db
update_option('ewww_image_optimizer_bulk_ngg_attachments', $attachments);
die;
}
示例14: ngg_Thumbnail
<?php
require_once '../config.php';
require_once nggGallery::graphic_library();
// Pull the image from the NextGen DB
$pictureID = $_REQUEST['pictureID'];
$pic = nggdb::find_image($pictureID);
// If Processing the Crop
if (!empty($_POST['ngg_crop'])) {
$image = new ngg_Thumbnail($pic->imagePath, TRUE);
// Create backup
@copy($image->fileName, $image->fileName . '_backup');
$image->crop($_POST['ngg_crop']['x1'], $_POST['ngg_crop']['y1'], $_POST['ngg_crop']['cropwidth'], $_POST['ngg_crop']['cropheight']);
$image->save($image->fileName);
// Save the new MetaData
nggdb::update_image_meta($pictureID, array('width' => $_POST['ngg_crop']['cropwidth'], 'height' => $_POST['ngg_crop']['cropheight']));
exit;
}
echo '<div class="ngg_crop">';
echo '<form class="ngg_crop_form" action="' . $nggcropobj->plugin_path . 'ajax/imagecrop.php" method="post">';
echo '<input type="hidden" id="pictureID" name="pictureID" value="' . $pictureID . '">';
echo '<input type="hidden" id="cropprocess" name="ngg_crop[cropprocess]" value="1">';
echo '<input type="hidden" id="x1" name="ngg_crop[x1]" />';
echo '<input type="hidden" id="y1" name="ngg_crop[y1]" />';
echo '<input type="hidden" id="x2" name="ngg_crop[x2]" />';
echo '<input type="hidden" id="y2" name="ngg_crop[y2]" />';
echo '<table cellspacing="3">';
echo '<tr>';
echo '<td class="ngg_crop_image">';
echo '<img src="' . $pic->imageURL . '?' . rand(0, 10000) . '" id="cropthis" style="display: none">';
echo '</td>';
示例15: maybe_import_meta
/**
* Maybe import some meta data to the database. The functions checks the flag 'saved'
* and if based on compat reason (pre V1.4.0) we save then some meta datas to the database
*
* @since V1.4.0
* @param int $id
* @return result
*/
function maybe_import_meta($id)
{
require_once NGGALLERY_ABSPATH . '/lib/meta.php';
$image = new nggMeta($id);
if ($image->meta_data['saved'] != true) {
//this flag will inform us the the import is already one time performed
$meta['saved'] = true;
$result = nggdb::update_image_meta($image->pid, $meta['common']);
} else {
return false;
}
return $result;
}